Disable the right mouse button code

Source: Internet
Author: User

1. Disable the mouse key code/prohibit page check/prohibit Save As/anti-copy code

Press CTRL + C to copy the code<textarea></textarea>Press CTRL + C to copy the code

2. Disable the left and right mouse button

1 <script language=javascript> 2 <!--3 if (window. Event) 4 document.captureevents (event.mouseup); 5 function Nocontextmenu () {6 event.cancelbubble = True 7 Event.returnvalue = false; 8 return false; 9}10 function Norigh Tclick (e) {One-if (window. Event) {E.which = = 2 | | e.which = = 3) return false;14}15 else16 if (Event.button = = 2 | | event.button = = 3) {EV ent.cancelbubble = True18 Event.returnvalue = false;19 return false;20}21}22 document.oncontextmenu = Nocontextmenu; For ie5+23 document.onmousedown = Norightclick; For all Others24//-->25 </SCRIPT>

3. Disable the Check code

1 <script language=javascript>2 document.oncontextmenu=new Function ("event.returnvalue=false;"); 3 document.onselectstart=new Function ("event.returnvalue=false;"); 4 </SCRIPT>

4. Prohibit Save As

1 <noscript>2 <iframe src= "/*.htm" ></iframe>3 </noscript>

5. Anti-copy/copy code

1 <body leftmargin=0 topmargin=0 >

6. Disable text selection

1 <script type= "Text/javascript" > 2 var omitformtags=["input", "textarea", "select"] 3 omitformtagsomitformtags= Omitformtags.join ("|") 4 function Disableselect (e) {5 if (Omitformtags.indexof (E.target.tagname.tolowercase ()) ==-1) 6 return false 7} 8 function reenable () {9 return true10}11 if (typeof document.onselectstart!= "undefined") document.ons Electstart=new Function ("return false") else{14 document.onmousedown=disableselect15 document.onmouseup= ReEnable16}17 </script>

7. Prohibit save page as

1 <noscript><iframe src= "/*.html>";</iframe></noscript>

8. Disable text selection

1 <script type= "Text/javascript" > 2  3 var omitformtags=["input", "textarea", "select"] 4  5 Omitformtagsomitformtags=omitformtags.join ("|") 6  7 function Disableselect (e) {8 if (Omitformtags.indexof ( E.target.tagname.tolowercase ()) ==-1) 9 return false10}11 function reenable () {return true14}15 if (typeof Docume nt.onselectstart!= "undefined") document.onselectstart=new Function ("return false") else{19 Document.onmousedown =disableselect20 Document.onmouseup=reenable21}22 </script>

9. Disable Right-click

1 <script>2 function Stop () {3 return false;4}5 document.oncontextmenu=stop;6 </script>

10. Real right-click masking

1 <script language= "JavaScript" > 2 <!--3  4 if (window. Event) 5  document.captureevents (event.mouseup); 6  7 function Nocontextmenu () 8 {9 event.cancelbubble = True10 ev Ent.returnvalue = false;11 return false;13}14 function Norightclick (e) (window. Event)  (E.which = = 2 | | e.which = 3)  return false;21}22 else23  if (Event.button = = 2 | | event.but ton = = 3)  {  event.cancelbubble = true26  event.returnvalue = false;27  return false;28  }29 30} Document.oncontextmenu = Nocontextmenu; For ie5+33 document.onmousedown = Norightclick; For all others34//-->35 </script>

Disable the right mouse button code (GO)

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.