【问题标题】:loading site in iframe has error in IE在 iframe 中加载站点在 IE 中出现错误
【发布时间】: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


    【解决方案1】:

    好吧,如果您只想在弹出窗口关闭时检查,那么您可以启动外部计时器来检查:

    var checkPopup = window.setInterval(function() {
        if (newwindow.closed) {
            window.clearInterval(checkPopup);
            document.location.reload();
        }
    }, 100);
    

    这样你就不用依赖弹出窗口本身的花哨脚本了。

    【讨论】:

    • 嘿,嘿!在我可以再次检查这个线程之前这样做了。谢谢! :)
    猜你喜欢
    • 2018-02-07
    • 1970-01-01
    • 2013-01-26
    • 2015-05-16
    • 1970-01-01
    • 2012-04-04
    • 1970-01-01
    • 2012-08-14
    相关资源
    最近更新 更多