我正在使用window.open()打开一个新窗口,当我使用window.focus()时,它会出现错误"无法获得未定义或null参考的属性焦点",使用MS Edge
我检查了这个问题,并解决了IE的问题:在窗口对象上调用focus()时面向IE11的问题
但是,此问题仍在 MS Edge 上发生。因此,这不应该是重复的。
我能够打开Intranet站点而不会出错,但是当我在弹出窗口中打开任何外部站点时,它会给该弹出窗口。
我在MSDN上看到了此链接,该链接指出增强的受保护模式一直在MS Edge中运行。这可能是问题的原因吗?
我已经可以在Internet选项中使用受保护的模式和增强的保护模式。
请建议??
folvowing是我的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); }
}
您问题的答案可能是在其他文章中...
focus()在边缘浏览器中不起作用