清空代码防止查看源代码

  1. <html>  
  2. <head>  
  3. <script language="javascript">  
  4. function clear(){  
  5.  Source=document.body.firstChild.data;  
  6.  document.open();  
  7.  document.close();  
  8.  document.title="看不到源代码";  
  9.  document.body.innerHTML=Source;  
  10. }  
  11. </script>  
  12. </head>  
  13. <body onload=clear()>  
  14. </body>  
  15. </html>  


这招算是目前网上公布的防止查看源代码的方法中最好的了,当然了,要看还是办法的.

比如在地址栏中输入:

<br>
javascript:alert(document.documentElement.outerHTML); 

原文地址:https://www.cnblogs.com/jehnjehn/p/2603683.html