代码改变世界

javascript清空网页代码防止查看源代码

2012-01-16 14:25  Alaric  阅读(200)  评论(0编辑  收藏  举报

javascript清空网页代码防止查看源代码

<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()>
</body>
</html>

这招算是目前网上公布的防止查看源代码的方法中最好的了,当然了,要看还是办法的,比如在地址栏中输入javascript:alert(document.documentElement.outerHTML);