【问题标题】:javascript window.focus() giving error oin MS Edge when opening internet linkjavascript window.focus() 在打开 Internet 链接时在 MS Edge 中给出错误
【发布时间】:2017-03-15 07:37:23
【问题描述】:

我正在使用 window.open() 打开一个新窗口,当我使用 window.focus() 时,使用 MS Edge 时出现错误“无法获取未定义或空引用的属性焦点”

我检查了这个问题,它解决了 IE 的问题: IE11-facing issue while calling focus() on window object

MS Edge 上仍会出现此问题。所以这不应该是重复的。

我能够打开 Intranet 站点而不会出现任何错误,但是当我在弹出窗口中打开任何外部站点时,它会给出此弹出窗口。

我在 msdn 上看到了这个链接,它指出增强保护模式一直在 MS Edge 中运行。这可能是问题的原因吗?

我已经在 Internet 选项中启用了保护模式和增强保护模式。

请推荐??

以下是我的 javascript 函数:

function LaunchCenteredWindowWithBars(windowWidth, windowHeight, windowName, windowUri) {
    try {
        var centerWidth = (window.screen.width - windowWidth) / 2;
        var centerHeight = (window.screen.height - windowHeight) / 2;

        newWindow = window.open(windowUri, windowName, 'width=' + windowWidth +
                ',height=' + windowHeight +
                ',left=' + centerWidth +
                ',top=' + centerHeight +
                ',toolbar=1,location=1,menubar=1,scrollbars=yes,status=yes,resizable=yes');

        newWindow.focus();
    }
    catch (e) { alert(e.message); }
}

【问题讨论】:

标签: javascript microsoft-edge


【解决方案1】:

您的问题的答案可能在其他帖子中...

focus() is not working in edge browser

【讨论】:

    猜你喜欢
    • 2016-04-23
    • 1970-01-01
    • 2020-07-29
    • 1970-01-01
    • 2022-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-26
    相关资源
    最近更新 更多