下面的脚本放在网站入口页面:
<script language='javascript' type='text/javascript'>
window.location.href='wp';
if(window.top.location !==window.location ){ top.location.href=self.location.href;}
</script>
原理就是通过href的值来判断,如果不是本域的地址,强行跳回原地址。
同样加CSP内容安全策略也可以达到同样的目的。
本文介绍了一种防止网页被恶意框架嵌套的方法,通过使用JavaScript重定向和Content Security Policy(CSP)策略,确保网站的安全性和用户体验。当检测到非本域地址时,会强制跳回原地址。
下面的脚本放在网站入口页面:
<script language='javascript' type='text/javascript'>
window.location.href='wp';
if(window.top.location !==window.location ){ top.location.href=self.location.href;}
</script>
原理就是通过href的值来判断,如果不是本域的地址,强行跳回原地址。
同样加CSP内容安全策略也可以达到同样的目的。
1457
2226
5550
1万+

被折叠的 条评论
为什么被折叠?