1、首先声明一个函数为clear
function clear()
2、对该页面body的源代码资源设置为不可读取
Source=document.body.firstChild.data;
document.open();
document.close();
document.body.innerHTML=Source;
3、在html页面的body中执行clear
<body onload="clear()">
4、完整禁止查看网页源代码的写法
<!--把下面代码加到<head>与</head>之间-->
<script language="javascript">
function clear(){
Source=document.body.firstChild.data;
document.open();
document.close();
document.body.innerHTML=Source;
}
</script>
</head>
<!--把<body>改为-->
<body onload="clear()">
OK了,现在可以鼠标右键点击查看是否有效