设置about:blank作为iframe的源在IE中有副作用

时间:2015-01-12 13:52:52

标签: javascript iframe cors

我有一个JS代码,用src="about:blank"创建一个隐藏的iframe(如果用户不点击打开它,我就不加载iframe的内容),当用户需要时要查看文件的内容,我只需更改iframe的src

整个代码要粘贴太多,但要点是:

// executed on document ready
iframeView = document.createElement('iframe')
iframeView.src = "about:blank"

// executed when the user clicks the button to show the iframe
iframeView.src = "http://example.com/some-url

然而,有时候(关键字是有时 - 即约4/5次),在IE上,iframe中的页面会抛出错误并且不会在该页面上执行任何JS :

  

原点:在Access-Control-Allow-Origin标题中找不到。

我认为这与我在页面加载上设置的about:blank有关。但为什么?为什么只在IE?

修改:尝试设置src="",摆脱了错误,但iframe内容页面上的JS仍未运行。

0 个答案:

没有答案
相关问题