JS Input text box disable right-click and copy-paste function code

Source: Internet
Author: User

The code is as follows:

1 function Click (e)2 { 3 if(document.all)4 { 5 if(Event. button==1||Event. button==2||Event. button==3) 6 { 7oncontextmenu='return False'; 8 } 9 } Ten if(document.layers) One {  A if(E.which = =3)  - {  -oncontextmenu='return False';  the }  - }  - }  - if(document.layers) + {  - document.captureevents (event.mousedown); + }  Adocument.onmousedown=Click; atDocument.oncontextmenu =NewFunction ("return false;")  - varTrxdyel=true  - varhotkey= - /*Hotkey is the key value of the hotkey, is the ASII code, here 99 for the C key*/  - if(document.layers) - document.captureevents (Event.keydown) - function Gogo (e) in {  - if(document.layers) to {  + if(E.which==hotkey &&Trxdyel) - {  theAlert'Operation error. Maybe you pressed the wrong button!');  * }  $ } Panax Notoginseng Else if(document.all) - {  the if(Event. Keycode==hotkey&&trxdyel) {alert ('Operation error. Maybe you pressed the wrong button!'); }}  + }  ADocument.onkeydown=gogo

The above JS code to write to the JS file named Xp.js and put into the script folder, the reference needs to pay attention to set charset= "gb2312", otherwise the message will be garbled. Page References:

The code is as follows:

1 <script src=". /script/xp.js "type="text/javascript" charset="gb2312 "></script>

1. The right mouse button will be completely shielded

1oncontextmenu="Window.event.returnvalue=false" 2<table Border oncontextmenu=return(false) > <td> no</table>Available for table3 function Click () {4 if(Event. button==2) { 5Alert'Sorry, the right button is disabled on this page! ') 6 } 7 } 8Document.onmousedown=click

2. Deselect, prevent copying
1 <body onselectstart="return False">

3. No pasting

1 onpaste="return False"

4. Prevent replication

1 oncopy="return false; " oncut="return false; "

JS Input text box disable right-click and copy-paste function code

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.