热门标签 | HotTags
当前位置:  开发笔记 > 前端 > 正文

让页面不允许iframe嵌入,更加安全

由于嵌入iframe的嵌入使得网站变的更不安全,如何能防止网页禁止被iframe嵌入呢?下面给出几个企业网站的应对方法:腾讯qq空间:

由于嵌入iframe的嵌入 使得网站变的更不安全, 如何能防止网页禁止被iframe嵌入呢? 


下面给出几个企业网站的应对方法:

 

腾讯qq空间:

 

Js代码   收藏代码
  1. document.domain="qq.com";var _s_=new Date(),g_T={},siDomain="ctc.qzonestyle.gtimg.cn",g_iUin=499469859,g_iLoginUin=499469859;g_T.fwp=[_s_];document.namespaces&&document.namespaces.add&&(document.namespaces.add('qz''http://qzone.qq.com/'),document.namespaces.add('x''http://qzone.qq.com/'));var QZFL={};QZFL.event={};QZFL.event.getEvent=function(evt){var evt=window.event||evt,c,cnt;if(!evt&&window.Event){c=arguments.callee;cnt=0;while(c){if((evt=c.arguments[0])&&typeof(evt.srcElement)!="undefined"){break;}else if(cnt>9){break;}c=c.caller;++cnt;}}return evt;};QZFL.event.getTarget=function(evt){var e=QZFL.event.getEvent(evt);if(e){return e.srcElement||e.target;}else{return null;}};var QZFF_M_img_ribr=[];QZFL.media={reduceImgByRule:function(ew,eh,opts,cb){QZFF_M_img_ribr.push(QZFL.event.getTarget());},adjustImageSize:function(w,h,trueSrc,cb,errCallback){QZFF_M_img_ribr.push(QZFL.event.getTarget());},reduceImage:function(){QZFF_M_img_ribr.push(QZFL.event.getTarget());},getImageInfo:function(){QZFF_M_img_ribr.push(QZFL.event.getTarget());}};g_T.fwp[1] = new Date();  
 

 

淘宝前端:

 

Js代码   收藏代码
  1. if(window.top !== window.self){ window.top.location = window.location;}  
 

 

从性能上看 腾讯的更为专业,更安全. 不过我还是比较爱参考淘宝的, 哈哈 各位怎么看。


推荐阅读
author-avatar
Caroline19921009
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有