views:

95

answers:

2

Hi,

I created a canvas object in my firefox plugin and now, I want to access the same from a webpage (The feature on the webpage will only work if the plugin is installed and the browser is FF).

Now, usually we access DOM elements inside a page through the browser plugin. How can I access it the other way round - i.e access the canvas element inside the plugin from the JS inside a webpage?

Thanks Kapil

+2  A: 

There is no way for JavaScript in a web page to interact with elements defined inside a Firefox extension.

Elements defined inside the Firefox extensions are part of the browser user interface (chrome). Since web pages run JavaScript with restricted privileges they cannot do a lot of things and among them, they cannot reference or interact directly with the chrome elements.

JavaScript code running in the extension can access elements defined in the web pages because it has high privilege. So if you want both to interact, it must be initiated by the extension code.

And even when doing so, you have to be VERY careful or your extension could open a big security hole that could allow a malicious website to execute JavaScript with chrome privileges.

The following links can give you more information on this:

https://developer.mozilla.org/en/Security_best_practices_in_extensions

https://developer.mozilla.org/en/Code_snippets/Interaction_between_privileged_and_non-privileged_pages

fms
A: 

fms, then how does Firebug allow logging to its console?

mtip