Categories

The hidden window trick

I was working with an extension today and I came across the need to overlay browser.xul, but only have my overlay fired once-per-session.  So, say you write an extension that puts a toolbar in as well as display some XUL on startup, but you don’t want the XUL to display every time browser.xul is loaded (which is every time a new browser window is created).  johnm in the #extedev channel on irc.mozilla.org reminded me about the hidden window trick!  The basics is to call into nsIAppShellService and set a property value so that the next time your “onLoad()” function gets called, you can see if that property exists again.  The lifetime of any data that you create in the hidden window is for the session, so it’s the perfect example.

1 comment to The hidden window trick