chrome.browserAction.setPopup() - local html files only?

1,418 views
Skip to first unread message

Bubba Bubbs

unread,
Feb 9, 2012, 7:49:30 PM2/9/12
to Chromium-extensions, 6u66a...@gmail.com
I would like to be able to dynamically (at run-time) modify my
extension's popup, AND be able to specify a custom popup HTML file
that's loaded from my server.

In Firefox, I can easily accomplish this with XUL overlays which I can
specify at run-time (https://developer.mozilla.org/en/
XUL_Overlays#Loading_Overlays_at_Run-time).
And document.loadOverlay() (https://developer.mozilla.org/en/DOM/
document.loadOverlay) does allow me to specify a 'remote' URL for the
overlay.

Is the same possible in Chrome?

I've been playing with chrome.browserAction.setPopup( details ) API
(http://code.google.com/chrome/extensions/browserAction.html#method-
setPopup), but it seems that the "details.popup" param must specify a
local file, and not a remote URL.

Thanks

Mohamed Mansour

unread,
Feb 9, 2012, 7:57:40 PM2/9/12
to Bubba Bubbs, Chromium-extensions
Hi Bubba,

There is no API to load external popups but you can do that with plain JavaScript. What you could do (I have done that in the past):
  • Use an iframe + extension messaging within the popup. The iframe points to some external url not hosted in the extension.
  • Use templates (jQuery templates example), load those template files to your background page, and just use them to construct your popup.
  • Download the html contents using XHR and load them within the popup by constructing the DOM.
I usually use the template approach, but I use the popup iframe approach when I want to manage the entire popup in the server side so I don't have to push updates to the extension gallery. I am not a fan of downloading the HTML contents, templating seems safer.

Hope this helped!

Mohamed Mansour
http://mohamedmansour.com/+



--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.


Ken Walker

unread,
Apr 18, 2020, 12:53:07 AM4/18/20
to Chromium Extensions, 6u66a...@gmail.com
We are looking same scenario, Could please help me @Bubba and @Mohamed?, how we can do that?

and @Mansour, Could you share link to the mailinglist archive with the mentioned post?
To unsubscribe from this group, send email to chromium-extensions+unsub...@chromium.org.
Reply all
Reply to author
Forward
0 new messages