How do I open a Crossrider popup based on a new page opening?

57 views Asked by At

I have a Crossrider extension which pops up a menu with a PNG image (in popup.html) when the extension icon is clicked. This works fine. But I also want to open popup.html in the same way when the user enters certain URL patterns (this part is also already working). Nothing I've tried for the last few hours works. Help! Extension ID: 83484

In background.js I have this:

    appAPI.browserAction.setPopup(
    {
        resourcePath: 'popup.html',
        height: popupDims[ appAPI.platform ].height,
        width:  popupDims[ appAPI.platform ].width
    });

In extension.js I have this:

    appAPI.openURL(
    {
        resourcePath: "popup.html",
        where: "window",
        focus: true,
        focusTimer: 5000,
        height: 300,
        width:  300
    });

I've also used "popup" instead of "window".

The popup.html window / popup doesn't display an image that's referenced in the file, even though the image is present in the popup that displays when I click on the extension icon. Also, the links work when the popup is displayed after an icon click, but not in the code above.

1

There are 1 answers

4
Shlomo On

The methods appAPI.openURL and appAPI.browserAction.setPopup are different with openURL providing a much limited environment; hence, whilst you can share the popup.html file between them, not all functionality (such as resources and some methods) supported in setPopup will be available to openURL. For more information, see the topics in the docs.

[Disclaimer: I am a Crossrider employee]