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