新闻建站cms系统、政府cms系统定制开发

广州网站建设公司-阅速公司

asp.net新闻发布系统、报纸数字报系统方案
/
http://www.ysneo.com/
广州网站建设公司
您当前位置:首页>网站技术

网站技术

网页iframe中在Chrome新版本中parent.document.write将不会执行

发布时间:2021/3/23 18:17:55  作者:Admin  阅读:534  

广告:阿里云采购优惠专区

var ifr=window.parent.window.frames['ifr'];

ifr.document.open();

// ifr.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n'); //会提示没有权限

ifr.document.write('<html>\n');

ifr.document.write('<head>\n');

ifr.document.write('<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />\n');

ifr.document.write('<style>*{margin:0px;padding:0px;line-height:20px;}</style>\n');

ifr.document.write('<script>function check(){if (document.form1.file2.value==""){alert("上传文件不能为空");return false;}}<\/script>\n');

ifr.document.write('</head>\n');

ifr.document.write('<body style="padding-top:3px;">\n');

ifr.document.write('<form id="form1" name="form1" method="post" enctype="multipart/form-data" onsubmit="return check();" action="'+editorpath+'uploadinc/Up.aspx">\n');

ifr.document.write('<input type="file" name="file2" id="file2" value="" style="width:230px;line-height:21px;height:21px;vertical-align:middle" /><input style="padding-left:3px;margin-left:1px;padding-right:3px;height:21px;line-height:21px;width:73px;vertical-align:middle" type="submit" name="Submit" value="开始上传" /></form>');

ifr.document.write('</body>\n');

ifr.document.write('</html>');

ifr.document.close();

针对以上的测试数据,Chrome 从 55版本开始,chrome 浏览器对用户使用的 document.write() 进行干预,如果符合以下所有的情况,页面 <script> 标签中的 document.write() 将不会被执行

1 用户处于缓慢的连接状态,特别是用户在 2G 时。(将来可能会延伸到慢速连接的其他用户,例如慢速 3G 或慢速 WiFi);

2 document.write() 在一个顶级的文件中,不适用于 iframe 中的 document.write 脚本,因为它们不会阻止主页面的呈现;

3 document.write() 中加载的脚本是会阻断解析的,如果脚本中有 async 或者是 defer 属性,那么它们还是会被解析执行;

4 document.write() 中加载的脚本和页面地址不是同个主域的,换句话说,chrome 浏览器不会阻止 script 标签符合 eTLD+1 规则的加载;

5 document.write() 中加载的脚本尚未在浏览器 HTTP 缓存中。缓存中的脚本不会导致网络延迟,并且仍然会执行。

广告:阿里云新人采购专场

相关文章
iframe
document.write
cms新闻系统购买咨询
扫描关注 广州阅速软件科技有限公司
扫描关注 广州阅速科技