【发布时间】:2013-02-19 17:36:52
【问题描述】:
我有一个要加载到弹出窗口内的 iframe 中的 url。父窗口有一个脚本,该脚本将脚本插入到弹出窗口中,以便弹出窗口关闭时弹出窗口会刷新父窗口。
function popUp(url) {
newwindow = window.open('', 'mypopup', '');
var tmp = newwindow.document;
tmp.write('<!DOCTYPE html><html><head><title>My Pop-Up</title></head>');
tmp.write('<body><iframe src="' + url + '" scrolling="no" frameborder="0"></iframe>');
tmp.write('<script type="text/javascript">window.onunload = function(){ window.opener.location.reload(); }</script></body></html>');
tmp.close();
}
我选择通过 javascript 编写 html,因为我无法编辑正在加载的页面(当弹出窗口关闭时,我需要真正重新加载父级。)这适用于 chrome 和 firefox,但 IE 有错误' SCRIPT5:访问被拒绝。'我不想访问正在 iframe 中加载的页面的任何部分,我只是想加载它。
当我在新的 IE 选项卡中打开页面时,它可以正常加载。此外,如果我通过 showModalDialog() 加载 url,页面也会加载。我希望我可以只使用 showModalDialog() 但是当在弹出页面上单击保存按钮时,会打开另一个弹出窗口,所以我想这是不可能的。
我们将不胜感激。
谢谢你:)
【问题讨论】:
标签: javascript internet-explorer iframe popup