Skip to content Skip to sidebar Skip to footer

Function Window.focus Doesn't Work In Ie (8, 9, 10, 11)

Here is my code, and this code to open new tab and focus on it. If tab is not opened yet, I will open it with specify name. If tab is opened, I will focus on it by using window.fo

Solution 1:

It's a security feature in Windows: http://support.microsoft.com/kb/979954

Here are a couple of work arounds to try:

http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/a250c431-9f09-441c-9b78-af067233ed78

Giving a child window focus in IE8

Solution 2:

This will work once due to the security issues

$(function() {
  $('#btnOpenTab').on('click', function(){
    openTab('http://google.com.vn', 'GG');
  });
});

functionopenTab(url, tabNm) {
  var mTab = window.open("", tabNm);
  mTab.document.write('<body onload="window.focus(); location.replace(\''+url+'\')">Please wait...</body>');
  mTab.document.close();
}

It failed to run twice because once the page loads it is no longer same origin.

I tried with an iFrame, but Google blocks that too now

Post a Comment for "Function Window.focus Doesn't Work In Ie (8, 9, 10, 11)"