Yep, either you do this on preference change which is probably easier
than going through all windows. I would rather hide those though,
instead of removing them.
You could also check on every menupopup if your items should be
displayed at all.
The following is for the contentContextMenu, but your should work similar:
var context=document.getElementById("contentAreaContextMenu");
if(context) {
context.addEventListener("popupshowing", function(event) {
rdr.contextMenuCheck(event); }, false);
context.addEventListener("popuphiding", function(event) {
rdr.contextMenuClean(event); }, false);
}
In the contextMenuCheck you should discard all events coming from
other contextmenus:
if(event.target.getAttribute('id')!='contentAreaContextMenu') return;
and then you can simply check for whatever you need and then finally set
document.getElementById(id).hidden=true|false;
Hope that helps.
xeen
On 4/9/07, Nickolay Ponomarev <[EMAIL PROTECTED]> wrote:
> On 4/9/07, Varun <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > My extension overlays browser.xul and has a tab contect menu item which is
> > added to the tab-context menu on window.load
> >
> > is there a way that i can remove this menuitem dynamically, if i already
> > have multiple windows open? I'm currently trying
> > 'ctsep' and 'ctTabCtx' are the id's of my seperator and menuitem.
>
> Are you doing this in response to a preference change? You might want
> to register a pref listener (via nsIPrefBranch2 interface) in each
> window, each of those listeners removing/adding the context menu in
> its own window. I.e.
>
> var menuItem = document.getElementById("your-id");
> menuItem.parentNode.removeChild(menuItem);
>
> Any particular problem you had with the code you posted?
>
> Nickolay
> _______________________________________________
> Project_owners mailing list
> [email protected]
> http://mozdev.org/mailman/listinfo/project_owners
>
_______________________________________________
Project_owners mailing list
[email protected]
http://mozdev.org/mailman/listinfo/project_owners