ServerBloke
ServerBloke

Reputation: 852

Firefox Addon with toolbar, access object from browser.xul

I am developing a Firefox addon which will be primarily a toolbar but will have some dialog/windows for things like preferences.

In browser.xul I declare my global variable which I will store all variables within:

var coolAddon = {};

Then in my toolbar I want to be able to call methods of coolAddon, for example on button clicks.

If I open a dialog from browser.xul, in the dialog I can access coolAddon using window.opener.coolAddon, which works well. The problem is this does not work on the toolbar - only on windows/dialogs. What happens in the toolbar is window.opener is null/undefined.

How can I access coolAddon that is declared in browser.xul, from within the toolbar? I don't want to redeclare it because I need to keep it's current property values (I realise my example does not currently have any properties or methods).

Upvotes: 0

Views: 189

Answers (1)

Mike Kaply
Mike Kaply

Reputation: 745

You should be able to access coolAddon directly from your toolbar. It is in the browser context.

Window.opener is only needed when you are in a completely different window.

Upvotes: 2

Related Questions