Web page source code protection (prohibit right-click, copy, save as, view source files)

Source: Internet
Author: User

1. Disable right-click menu
Copy codeThe Code is as follows:
<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)
Copy codeThe Code is as follows:
<Script type = "text/javascript" language = "javascript">
Function noCopy ()
{
Alert ("do not use Ctrl + C to copy! ");
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 the use of HTML tags in pages for caching, as shown below:
Copy codeThe Code is as follows:
<HEAD>
<META http-equiv = Pragma content = no-cache>
<META http-equiv = Cache-Control content = no-cache>
<META http-equiv = Expires content = 0>
</HEAD>

Related Article

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.