0

I have a button, clicking on it, will to open up a new tab.

$('#got-it').click(function(){

    $('#myModal').modal('hide');

    var ajax = $.ajax({url: '/api/{{ $cpe_mac }}/gateway'});
    ajax.done(function (gw) {
        $('#ajaxActivateFB').fadeOut();
        $('#gw-table').fadeIn();

        var url = "https://www.facebook.com/wifiauth/config?gw_id="+gw['gw_id'];
        window.open(url, '_blank'); <----- ONLY works in Chrome
    });
});

I am not sure why this line :

window.open(url, '_blank'); <----- ONLY works in Chrome, but not IE, or firefox

How do I trigger a new tab that will work on all browsers ?

mcuenez
  • 1,579
  • 2
  • 20
  • 28
code-8
  • 54,650
  • 106
  • 352
  • 604
  • This minified example (https://jsfiddle.net/Obsidian_Age/frLoq1br/) works perfectly for me in all three browsers. It is likely a problem with your AJAX or modal (or possibly from you overwriting the .`open` function with a JavaScript `var open = xx`). I can't replicate either the AJAX or modal components, so could you please update your question so that it shows all relevant code in a [minimal, complete, and verifiable example](http://stackoverflow.com/help/mcve). – Obsidian Age Feb 23 '17 at 19:46
  • Possible duplicate of [Open a URL in a new tab (and not a new window) using JavaScript](http://stackoverflow.com/questions/4907843/open-a-url-in-a-new-tab-and-not-a-new-window-using-javascript) – mcuenez Feb 23 '17 at 19:49

1 Answers1

2

window.open method open new URL in a new browser window.
_blank - URL is loaded into a new window. This is the default. The open() method creates a new secondary browser window.

window.open(url, '_blank');

You are using above code to open new tab after a success of the request. It's working well for all the latest browsers including IE and Firefox, you have to check your codes for errors or for the success of ajax request.

Simply you can run below fiddle in any of new browser.

https://jsfiddle.net/himstar/2hqc2bgz/1/