0

「コピー保護」ページ専用の私の関数(以下に表示)。(実際には視覚的なものにすぎません。上級ユーザーはソースコードから取得できます。)この関数をテキスト領域、テキストボックスを除くすべてのページ部分で機能させるにはどうすればよいですか。 。どうすればこの結果を達成できますか?

(function($){

    $.fn.ctrl = function(key, callback) {
        if(typeof key != 'object') key = [key];
        callback = callback || function(){
            return false;
        }
        return $(this).keydown(function(e) {
            var ret = true;
            $.each(key,function(i,k){
                if(e.keyCode == k.toUpperCase().charCodeAt(0) && e.ctrlKey) {
                    ret = callback(e);
                }
            });
            return ret;
        });
    };


    $.fn.disableSelection = function() {
        $(window).ctrl(['a','s','c']);
        return this.each(function() {           
            $(this).attr('unselectable', 'on')
            .css({
                '-moz-user-select':'none',
                '-o-user-select':'none',
                '-khtml-user-select':'none',
                '-webkit-user-select':'none',
                '-ms-user-select':'none',
                'user-select':'none'
            })
            .each(function() {
                $(this).attr('unselectable','on')
                .bind('selectstart',function(){
                    return false;
                });
            });
        });
    }
})(jQuery);
4

1 に答える 1

2

あなたができるはずです

$('*').not('textarea, input[type="text"]').disableSelection();
于 2012-07-24T11:25:54.750 に答える