This article describes the jquery disable right-click, text selection function, the implementation of the Copy button can be compatible browser has IE, Firefox, Google Browser, you can refer to friends. IE browser refers to IE as the core browser is also supported, there are 360,QQ, etc.
The code is as follows:
1 //Disable Right-click, text-Select, copy-button2$ (document). Bind ("ContextMenu",function(){return false;}); 3$ (document). Bind ("Selectstart",function(){return false;}); 4$ (document). KeyDown (function(){returnKey (Arguments[0])}); 5 6 //prompt warning when pressing7 functionKey (e) {8 varKeynum; 9 if(window.event) {TenKeynum = E.keycode;//IE One}Else if(E.which) { AKeynum = E.which;//Netscape/firefox/opera - } - if(Keynum = = 17){ theAlert ("Disable copying of content! "); - return false; - } - } + - //Disable Right-click, text-Select, copy-button +$ (document). Bind ("ContextMenu",function(){return false;}); A$ (document). Bind ("Selectstart",function(){return false;}); at$ (document). KeyDown (function(){returnKey (Arguments[0])}); - - //prompt warning when pressing - functionKey (e) { - varKeynum; - if(window.event)//IE in { -Keynum =E.keycode; to } + Else if(E.which)//Netscape/firefox/opera - { theKeynum =E.which; * } $ if(Keynum = = 17) {Alert ("Disable copying of content! ");return false;} Panax Notoginseng } - the + //Shield right mouse button, CTRL + N, SHIFT+F10, F11, F5 refresh, backspace bar A functionDocument.oncontextmenu () {event.returnvalue=false;}//masking the right mouse button the functionWindow.onhelp () {return false}//Shielding F1 Help + functionDocument.onkeydown () { - if((Window.event.altKey) && $((window.event.keycode==37) | |//masking ALT + arrow key ← $(window.event.keycode==39))) {//Shielding Alt + arrow keys → -Alert ("Don't use ALT + arrow keys to forward or rewind the page!") "); -Event.returnvalue=false; the}if((event.keycode==8) | |//Mask BACKSPACE Delete key -(event.keycode==116) | |//Mask F5 Refresh keyWuyi(Event.ctrlkey && event.keycode==82)) {//Ctrl+r theEvent.keycode=0; -Event.returnvalue=false; Wu } - if(event.keycode==122) {event.keycode=0;event.returnvalue=false;}//Shielded F11 About if(Event.ctrlkey && event.keycode==78) event.returnvalue=false;//Shielding CTRL + N $ if(Event.shiftkey && event.keycode==121) event.returnvalue=false;//Shielded Shift+f10 - if(window.event.srcelement.tagname== "A" &&Window.event.shiftKey) -Window.event.returnvalue=false;//screen shift and left mouse button to open a new page - if((Window.event.altKey) && (window.event.keycode==115)) {//Shielded Alt+f4 AWindow.showmodelessdialog ("About:blank", "", "dialogwidth:1px;dialogheight:1px"); + return false; the } -}
jquery prohibits copying, disabling right-click, text selection, and copying keys