3

I have a project site which have links or buttons that open popups, and avoid opening duplicates by calling focus() if the requested window already exists. But Firefox ignores window.focus() for tabs, which makes the links seem like they're broken if you forget you already have the window open. This is even more confusing when sites reuse windows to load different content.

I have already tried :

     //First possibility
     $window.open(url,getLinkType(url)).focus();
     //Second possibility
     var win = $window.open(url,getLinkType(url));
     win.focus();

None of the above seems to work for firefox as firefox disregards the focus method after the open() and focuses on the first open(). Is there any work around which would set the focus on the new tab.

Sam Shk
  • 31
  • 3

1 Answers1

0

it seems firefox removed the support on focussing tabs, you could work with popups?

var google = window.open("https://www.google.com", "google", "height=500,width=800"),
    bing = window.open("https://www.bing.com", "bing", 'height=500,width=800');

$(function() {
    $("#google").click(function() {
        google.focus();
    });
    $("#bing").click(function() {
        bing.focus();
    });
});

Related questions:

Community
  • 1
  • 1
Veas
  • 160
  • 8
  • Doesn't works for firefox, the focus remains on the old tab. – Sam Shk Aug 15 '16 at 14:10
  • Check this one out: https://jsfiddle.net/kzLp8apq/ If you try to reuse a tab, the parent tab is refreshed but the control is not transferred to the child tab. In your case it was trying to open a new tab each time which is not exactly a requirement. – Sam Shk Aug 15 '16 at 17:42