Chrome: window.open opens a new tab instead of a new popup.

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 an old chrome version from v58 (58.0.3029.110) back will give the correct behavior when opening a new popup.

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

Is this a problem from within the browser itself? Or is something in my code invalidating it assuming the only change here is the browser version.

PS Trying this snippet in mozilla works correctly.

+3


source to share


1 answer


Chrome no longer likes location=1

to open pop-ups.

Change it to location=0

or location=no

and you're good to go.



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

location is only used in Opera.

+1


source







All Articles