简体   繁体   English

Window.focus() 在 IE11 中不起作用

[英]Window.focus() not working in IE11

I have the below javascript code which opens a url in new tab if it is not already opened.我有下面的 javascript 代码,如果它尚未打开,它会在新选项卡中打开一个 url。 But if it is already opened it just bring it to focus.但是,如果它已经打开,只需将其聚焦即可。 This code is working fine in Chrome.此代码在 Chrome 中运行良好。 But not in IE11.但不是在 IE11 中。 All the url are in intranet zone.所有的 url 都在 Intranet 区域中。

 var loadingTonl;
 $('#tonlsg').click(function(){
 var url="<Some url>";
 if(loadingTonl == undefined || loadingTonl.closed)
    loadingTonl = window.open(url,'tonlFrame');
 else
    loadingTonl.focus();
 })

window.open() in IE returns NULL if Protected Mode is Enabled如果启用保护模式,IE 中的window.open()将返回NULL

This option can be toggled by unchecking "Enable Protedcted Mode" in Tools -> Internet Options -> Security: "Security level for this zone".可以通过在工具 -> Internet 选项 -> 安全性:“此区域的安全级别”中取消选中“启用保护模式”来切换此选项。

You will not face this issue if the web page is accessed from a proper website(from Internet).如果从适当的网站(从 Internet)访问网页,您将不会遇到此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM