怎么让别人无法查看自己的网页源代码

时间:2026-02-16 04:26:27

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了,现在可以鼠标右键点击查看是否有效

© 2026 五度知识库
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com