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:


Solution 2:

This will work once due to the security issues

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

function openTab(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)"