我是靠谱客的博主 直率篮球,这篇文章主要介绍防止网页被嵌入框架的代码,现在分享给大家,希望可以做个参考。

try{

  top.location.hostname; //Chrome不报错

  if (top.location.hostname != window.location.hostname) {

    top.location.href =window.location.href; //其他浏览器有异常

  }}

catch(e){

  top.location.href = window.location.href;

}

ref:http://www.ruanyifeng.com/blog/2010/08/anti-frameset_javascript_codes_continued.html

 

if (self!=top){ window.top.location.replace(self.location); //打开自己网站的页面 }

ref:https://blog.csdn.net/shaerdong/article/details/53208511

最后

以上就是直率篮球最近收集整理的关于防止网页被嵌入框架的代码的全部内容,更多相关防止网页被嵌入框架内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(70)

评论列表共有 0 条评论

立即
投稿
返回
顶部