繁体   English   中英

动态添加iframe时不需要的页面重新加载

[英]unwanted page reload when dynamicly adding iframe

看起来它是一个Firefox Home严格的问题,并且由于Mozzilla放弃了对它的支持并在iStore中将其拉出来,我认为没有必要尝试解决方法( http://thenextweb.com/apps/2012/08/ 31 / mozilla-retires-firefox-home-ios-releases-source-code-github / ),无论如何我向他们发布了bug( https://bugzilla.mozilla.org/show_bug.cgi?id=853377 )如果有人有兴趣关注/解决


我有一个非常好的交叉浏览库使用iframe方法进行通信。

并且在iPhone上使用Firefox打开它直到最佳状态。 带有库的页面启动,然后魔术重定向。

我已经进入代码并尝试识别问题:

动态添加iframe后重新加载到iframe src。 我测试了以下内容:

  1. document.createElement('iframe')附加到文档
  2. document.createElement('iframe')追加到precreated div
  3. .innerHTML方法,其中包含预先创建的iframe代码
  4. frames['iframe_name'].location.src with frames['iframe_name'].location.src iframe with empty src
  5. .location.assign()
    • document.getElementById()失败
    • with frames['iframe_name']重定向
  6. 与jquery $('<iframe src="link"/>'). appendTo('#reportA'); $('<iframe src="link"/>'). appendTo('#reportA');
  7. 尝试也首先创建没有src的iframe,然后设置它
  8. 也用$('#iframe').attr('src','link')更新$('#iframe').attr('src','link')导致重定向

另外,我在日志上看到(在iframe中称为页面记录状态)。 实际上有两个调用,所以看起来首先是附加的iframe读入,然后在新页面中打开iframe src。

在解析我的代码时,我发现在代码的一部分中创建iframe时会出现问题,这是由我的js loader动态添加的。 我使用了以下追加脚本

var head = document.getElementsByTagName("head")[0];  
var script = null;  
script = document.createElement('script');  
script.type = 'text/javascript';  
var tag = Math.round(new Date().getTime() / 1000);  
script.src =  GLOBAL_VARIABLE_WITH_PATH_TO_URL+'jsc/include.js?'+tag ;  
head.appendChild(script);

也试过了

 document.write("<script src='"+FUTUREclickINFOpathS+"fcijsc/fci-include.js?"+tag+"'><\/script>");

UPDATE

还尝试在jquery $(document).ready()上附加irame - 当与document.write方法一起使用时,它工作正常,直到在setTimeout调用setTimeout

更奇怪的是,当在主静态js文件中使用setTimeout() ,会发生同样的事情。 我今天会尝试setInterval() ,看看发生了什么。

因此很明显,iframe的src上的任何更改都会导致父重新加载,即使iframe是预先创建的。 有什么想法吗?

PS。 对于一些不完整的句子感到抱歉,但我的头脑缠绕在那个问题上

您是否正在使用postMessage从iframe与父级进行通信? 我遇到了这个并注意到从iframe的脚本中删除parent.postMessage修复了它。 如果我找到一个,我会更新一种方法来解决这个问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM