Prevent others from viewing your page's source code

Source: Internet
Author: User

 completely prohibit viewing the Web page source code 
block Right-click, copy, select the full code:
 <script > Document.oncontextmenu =new Function ("Return false" =new Function ("return false" </script>  
Select the text or right-click to see

or

<body oncontextmenu= "return false" onselectstart= "return false" >
Select Text or right-click to see

How to view the source code
----to prevent visitors from viewing the source code of the Web page, first look at how to view the source code (IE 5.0 for example). One is the right-click menu mode; Second, the Window menu bar viewing mode, that is, select "View" * "source file" mode. To completely prohibit visitors from viewing the source code of the Web page, you must block these 2 ways to view the source code.

One: Screen Right-click menu View
----Now, many Web pages use the following code to screen the right-click menu:
< Script language=javascript>
Function Click () {
if (event.button==2) {alert
(' Masking right-click menu ');
}}
Document.onmousedown=click;
</script>

Other methods
<script language=javascript>function Click () {if (event.button==2) {alert (' Don't you peek! ‘);}} Document.onmousedown=click</script>

  

Prevent others from viewing your page's source code

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.