码迷,mamicode.com
首页 > 其他好文 > 详细

iframe

时间:2017-02-28 10:39:45      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:安全   element   dia   date()   网页   images   type   self   ima   

  • 让页面不允许iframe嵌入,更加安全的解决办法

Js代码  

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代码  

if(window.top !== window.self){ window.top.location = window.location;} 

 

  •  设置X-Frame-Options响应头防止网页被框架:

 防止某些重要网页被其他网站框架导入,可以给页面增加X-Frame-Options响应头,这样浏览器会依据X-Frame-Options的值来控制iframe框架的页面是否允许加载显示出来,IE下的效果如下(此内容无法再框架中显示。为了帮助保护在此网站中输入的信息安全,此内容的发行者不允许在框架中显示该信息),其他非IE核心浏览器会显示空白内容。

  • https网页无法含有http的网页frame

iframe

标签:安全   element   dia   date()   网页   images   type   self   ima   

原文地址:http://www.cnblogs.com/fengdeng/p/6477709.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!