【发布时间】: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); }
}
【问题讨论】:
-
忘记添加msdn链接:
-
尝试在“newWindow”前面添加“var”。还要检查 newWindow 是否不为空或未定义。