Opening a new window via my extension

46 views Asked by At

I am writing an extension that needs to open a page in a new popup window. However, whenever I try to open a window, the browser's popup blocker prevents the window from opening. I have the following code in my extension.js

appAPI.ready(function($) {
    var win = window.open("http://google.com", "", "width=200, height=100");
});
1

There are 1 answers

0
Shlomo On

Modern browser automatically block popups opened by the page. However, you can use the Crossrider appAPI.openURL method to opens windows without issue for all supported browsers.

So, using your example, the code would be:

appAPI.ready(function($) {
    appAPI.openURL({
        url: "http://google.com",
        where: "window",
        width: 200,
        height: 100
    });
});

[Disclosure: I am a Crossrider employee]