禁止複製和右鍵的jquery function

2015-06-11

禁止複製和右鍵的jquery function

//禁止右鍵,選取複製等等
$(window).on("contextmenu", function(e) {e.preventDefault();})
$(window).on("keydown", function(e) {if(e.keyCode == 123)e.preventDefault();})
disableSelection(document.body);

//禁止選取網頁內容及複製
function disableSelection(target){
            if (typeof target.onselectstart!="undefined") //For IE 
                    target.onselectstart=function(){return false}
            else if (typeof target.style.MozUserSelect!="undefined") //For Firefox
                    target.style.MozUserSelect="none"
            else //All other route (For Opera)
                    target.onmousedown=function(){return false}
            target.style.cursor = "default"
}

Contact

Github

Codepen

歡迎參觀我的賣場
© 2013 Copyright Digishot Web | Design Tools
Visitors【622539】
digishot webdesign studio