0

I have a function on the server that returns a URL.

I need to open this URL in a new tab, if the tab is already open, I need to set focus on the tab.

The first time I call the method it works well, but if the tab is already open, it only refreshes the page without the focus.

If I move the win.focus() outside the ajax it works on Chrome, but not in Firefox.

  $.ajax({
        url: myurl,
        dataType: 'text',
        data: { "id" : $('#selectOrder').val()}
        success: function (data) {        

            var win = window.open(data, 'mytab');
            win.focus();                      

        }

    });
default
  • 551
  • 8
  • 16
  • @AnilRedshift Unfortunately you are right about firefox, what bothers me is that it not work only inside the ajax on chrome. Thanks! – default Jul 30 '18 at 20:08
  • I found the solution by attributing the URL to a link and then using jQuery to open the link – default Jul 30 '18 at 20:20

0 Answers0