简体   繁体   English

jQuery函数无法正常工作

[英]Jquery function doesn't work properly

My page protection JS file looks like that 我的页面保护JS文件看起来像这样

(function($){
$.fn.disableSelection = function() {
    return this.each(function() {           
        $(this).attr('unselectable', 'on')
               .css({
                   '-moz-user-select':'none',
                   '-webkit-user-select':'none',
                   'user-select':'none',
                   '-ms-user-select':'none'
               })
               .each(function() {
                   this.onselectstart = function() { return false; };
               });
    });
};
})(jQuery);

var message="Bu səhifədən material kopyalamaq qadağandır!"; 

function clickIE4(){
    if (event.button==2){
        alert(message);
        return false;
    }
}
function clickNS4(e){
    if (document.layers||document.getElementById&&!document.all){
        if (e.which==2||e.which==3){
            alert(message);
            return false;
        }
    }
}
if (document.layers){
    document.captureEvents(Event.MOUSEDOWN);
    document.onmousedown=clickNS4;
} else if (document.all&&!document.getElementById){
    document.onmousedown=clickIE4;
}
document.oncontextmenu=new Function("alert(message);return false")

All functions work well except $.fn.disableSelection . 除$ .fn.disableSelection之外,所有功能均正常运行。 It must disable selection. 它必须禁用选择。 But I can select any piece of text. 但我可以选择任何文本。 What am I missing? 我想念什么?

You only define the function in this code. 您只能在此代码中定义函数。 Execute the function. 执行功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM