jquery prohibits copying, disabling right-click, text selection, and copying keys

Source: Internet
Author: User
Tags delete key

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.