Shield right-click code (prevent malicious webpage copy)

Source: Internet
Author: User

About how to block the right-click Copy code. There are several possible types:
<Head> input under the statement

  1. <Body onselectstart = "Return false;" oncontextmenu = "Return false;">

Add the following code at the bottom of the system homepage file (default. asp) and log file (article. asp). Both files are in the root directory.

  1. <NoScript>
  2. <IFRAME scr = "*. htm"> </iframe>
  3. </NoScript>
  4. <Script language = "JavaScript">
  5. Document. oncontextmenu = new function ("event. returnvalue = false ;");
  6. Document. onselectstart = new function ("event. returnvalue = false ;");
  7. </SCRIPT>

The advantage is that it is simple and easy to crack, but the protection is not enough.
Some methods are found:
First, JavaScript code that disables the right-click, Ctrl, and copy Functions

Some t website pages cannot use the right-click and copy functions, or even the ctrl key. How can this effect be achieved? In fact, it is easy to call a piece of JS Code.
The following text box shows the Code required to achieve the effect:

  1. Function click (e ){
  2. If (document. All ){
  3. If (event. Button = 1 | event. Button = 2 | event. Button = 3 ){
  4. Oncontextmenu = 'Return false ';
  5. }
  6. }
  7. If (document. layers ){
  8. If (E. Which = 3 ){
  9. Oncontextmenu = 'Return false ';
  10. }
  11. }
  12. }
  13. If (document. layers ){
  14. Document. captureevents (event. mousedown );
  15. }
  16. Document. onmousedown = click;
  17. Document. oncontextmenu = new function ("Return false ;")
  18. VaR travel = true
  19. VaR hotkey = 17/* hotkey is the key value of the hotkey, which is an asii code. Here 99 represents the C key */
  20. If (document. layers)
  21. Document. captureevents (event. keydown)
  22. Function Gogo (E)
  23. {If (document. layers ){
  24. If (E. Which = hotkey & travel ){
  25. Alert ("Operation error. Maybe you have pressed the wrong button! ");}}
  26. Else if (document. All ){
  27. If (event. keycode = hotkey & travel) {alert ("Operation error. Maybe you have pressed the wrong button! ");}}
  28. }
  29. Document. onkeydown = gogo

Save the above Code as a JS file, and then use <! -- # Include file = "*. js" --> you can call it. * indicates the file name you saved!
Disable right-click and automatically navigate
Script description:
Add the following code to the <body> area:

  1. <Script language = "JavaScript">
  2. If (navigator. appname. indexof ("Internet Explorer ")! =-1)
  3. Document. onmousedown = nosourceexplorer;
  4. Function nosourceexplorer ()
  5. {
  6. If (event. Button = 2 | event. Button = 3)
  7. {
  8. Alert ("right-click prohibited... go to the homepage! ");
  9. Location. Replace ("http://xiaoc.icpcn.com ");
  10. }
  11. }
  12. </SCRIPT>

Third, disable right-click code
Add the following code between head and head.

  1. <Script language = "JavaScript">
  2. Document. oncontextmenu = new function ("event. returnvalue = false ;");
  3. Document. onselectstart = new function ("event. returnvalue = false ;");
  4. </SCRIPT>

The advantage is that JS scripts are used, but they are complicated and easy to crack.

Recommended Methods:
Insert the following code into the webpage script (header. asp:

  1. <Body oncontextmenu = 'Return false' ondragstart = 'Return false' onselectstart = 'Return false' onselect = 'document. selection. empty () 'oncopy = 'document. selection. empty () 'onbeforecopy = 'Return false' onmouseup = 'document. selection. empty () '>

The code above indicates that it is blank when the mouse selects text
The advantage is that the Code is easy to implement without the support of JS scripts. In addition, the clipboard is also cleared after normal cracking and replication.
Here, I remove onmouseup = 'document. selection. empty () ', because this Code indicates that when the mouse key pops up, the selected content is blank, which will affect normal login.

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.