Prohibit web page right-click, copy, save as, View Source file and other functions to implement web page source code protection

Source: Internet
Author: User

Prohibit webpage right-click, copy, save as, View Source file and other functions to implement webpage source code protection. The following methods are summarized to implement simple web page protection. The specific code is as follows:

1. Disable right-click menu

<Script type = "text/javascrpt" language = "javascript"> // method 1 function noMenuOne () {alert ('prohibit right-click menu! '); Return false;} document. oncontextmenu = noMenuOne; // method 2 function noMenuTwo () {if (event. button = 2) {alert ('prohibit right-click menu! '); Return false ;}} document. onmousedown = noMenuTwo; </script>

2. Prohibit replication (Ctrl + C)

<Script type = "text/javascript" language = "javascript"> function noCopy () {alert ("do not use Ctrl + C for copying! "); Event. returnValue = false ;}</script> // <body oncopy =" noCopy () ">

3. Save as prohibited

<! -- Add code between <body> </body> --> <noscript> <iframe src = '*. htm'> </iframe> </noscript>

4. Disable caching
Disable caching by using the following HTML tag in the page:

<HEAD> <META http-equiv=Pragma content=no-cache> <META http-equiv=Cache-Control content=no-cache> <META http-equiv=Expires content=0> </HEAD>
Articles you may be interested in
  • Run the code preview code, save the code as, and copy the implementation of the code function.
  • PHP restricts domain names to protect source code from being copied
  • Using JavaScript to prohibit browsers from directly copying article content
  • Windows cannot start the hardware device because its configuration information (in the Registry) is incomplete or damaged. (Code 19) Solution
  • Js address bar special effects (display the size of all images with links on the page and view the height of the current browser)
  • Php clears (deletes) the files in the specified directory, and does not delete the directory folder.
  • Php reads the Directory and lists the functions that display the files in the directory.
  • Embedding the baidu search box in a webpage

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.