3

I have this snippet:

HTML

<a href="#" class="option-link" data-url="https://www.google.com">CLICK ME</a>

JS

var popup = undefined;

// Option links toggle
$('.option-link').on('click', function (e) {

    e.preventDefault();

    var url = $(this).data('url');

    if (typeof url !== 'undefined' && url) {

        function __popup_open(link) {
            return window.open(
                link, 
                'same_window',
                'width = 940, height = 620, toolbar = 0, menubar = 0, location = 1, status = 1, scrollbars = 0, resizable = 0, left = 0, top = 0'
            );
        }


        if (typeof popup == 'undefined' || popup.closed) {

            popup = __popup_open(url);

        } else {

            popup.close();
            popup = __popup_open(url);
        }

        popup.focus();
    }

});

Running the script on old version of chrome from v58 (58.0.3029.110) backwards will give the right behaviour of opening a new popup window.

But after I updated my browser to v59 (59.0.3071.104), instead of opening a popup window, it opens a new browser tab.

Is this an issue from the browser itself? Or something in my code makes it not work same provided that the only change here is the browser version.

PS Trying this snippet to mozilla works correctly.

Vainglory07
  • 5,073
  • 10
  • 43
  • 77

1 Answers1

1

Chrome no longer likes location=1 for opening popups.

Change it to location=0 or location=no and you are good to go.

From the spec https://www.w3schools.com/jsref/met_win_open.asp

location yes is used only in Opera.

J6ksu
  • 11
  • 3