防止查看网页源代码

来源:互联网 发布:赵薇 马云关系 知乎 编辑:程序博客网 时间:2024/05/17 03:59
这招算是目前网上公布的防止查看源代码的方法中最好的了,当然了,要看还是办法的,比如在地址栏中输
  
  入"javascript:alert(document.documentElement.outerHTML);"。
   但好像测试了几下,简单的没多少代码的还行,对于JS较多的,就不行了。
   
   <html>
   
   <head>
   
   <script language="javascript">
   
   function clear(){
   
   Source=document.body.firstChild.data;
   
   document.open();
   
   document.close();
   
   document.title="看不到源代码";
   
   document.body.innerHTML=Source;
   
   }
   
   </script>
   
   </head>
   
   <body onload=clear()>
   
   <!--
   
   <a href="http://www.zgsj.com">中国数据</a>可惜你看不到!
   
   -->
   
   </body>
   
   </html>