How to call javascript function in popup.html from background page ( in chrome extensions)?
A:
Unfortunately it is not possible to get a direct reference to the popup page, the main reason is that the page might not be open when you try and call it.
You have to use message passing to pass a message between popups and background pages.
I would ask is there a specific need to have the function in the popup and not have it re-factored into a separate shared file.
Kinlan
2010-04-11 18:25:04
I wanto modify popup depending of the content of the page.
kamil
2010-04-12 22:44:42
I would place the logic in the background page, and in the onload event on your popups document>body get the information from the background page. You can also change the physical background page by using: setPopup http://code.google.com/chrome/extensions/trunk/browserAction.html#method-setPopup
Kinlan
2010-04-13 08:02:29
A:
Would be best to place that functionality in a Background page instead and within your popup you can do:
var bkg = chrome.extension.getBackgroundPage()
bkg.someBackgroundPageFunction();
Mohamed Mansour
2010-04-11 20:39:24
A:
Thanx for conributions. I found http://markashleybell.com/articles/building-a-simple-google-chrome-extension/ which solved the problem.
kamil
2010-04-13 00:09:29