IE:window.open返回null [英] IE: window.open returning null

查看:246
本文介绍了IE:window.open返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在点击事件中,我正在运行此代码:

on a click event, I am running this code:

win = window.open(a.href);
i = setInterval(function () {
    if (win.closed) {
        /* do things */
    }
}, 250);

这在Firefox和Chrome中运行良好,但在IE(9)中它表示胜利未定义或空值。我该如何解决这个问题?

this works fine in Firefox and Chrome, but in IE (9) it says that win is undefined or null. How can I work around this?

编辑:窗口IS在IE中正确打开,只是对它的引用不会像在Firefox /中一样保存在win中Chrome。

The window IS opened correctly in IE, it's just that a reference to it is not saved in win like it is in Firefox/Chrome.

推荐答案

在窗口中添加名称:

win = window.open(a.href, "myWin");

这篇关于IE:window.open返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆