0

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.

Mike D.
  • 1
  • 1
  • You should a) show what you've tried, and b) explain what 'doesn't work' means. You'll be much more likely to get help with that info in the post. – elhefe Mar 26 '16 at 19:10

1 Answers1

0

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]

Shlomo
  • 3,763
  • 11
  • 16
  • Hi Shlomo. Thanks for the feedback. My issue is: how do I invoke the popup to display every time a certain URL is opened in the active tab? – Mike D. Mar 30 '16 at 18:50
  • Sorry, above comment cut short. Do I use a message from extension.js to background.js? – Mike D. Mar 30 '16 at 18:50
  • I would consider doing it in the _background.js_ using [appAPI.tabs.onTabSelectionChanged](http://docs.crossrider.com/#!/api/appAPI.tabs-method-onTabSelectionChanged) where the URL is available in the parameters passed to the method. – Shlomo Mar 31 '16 at 10:37
  • Thanks Shlomo. I'll give that aa try! – Mike D. Mar 31 '16 at 10:46