Latest |Kites |Pictures |Programming |Life
[filed under Programming]XUL Firefox add on sidebar open close events

Tags: Firefox 3.x add-on sidebar.

What this post is about

I am coding a FIrefox add-on. It is fun. I am making a sidebar that you can drag and drop stuff onto. I need to know when the user has opened it or closed it (so I can persist the data) so after a lot of googling I figured it out.

The code

This is how you can watch the open and close events of a sidebar. In your sidebar javascript file put this in:

var skratch = {
    onLoad: function(e) {
        alert('load');
    },
    onUnload: function(e) {
        alert('close');
    }
}

window.addEventListener("load", function(e) { skratch.onLoad(e); }, false);
window.addEventListener("unload", function(e) { skratch.onUnload(e); }, false);

Hope that helps someone.

Use this with 'save to file' to persist data in your add-on - happy days. Happy fuckin days, man.

Here is some save to file goodness (note: the code is GPL):

http://code.flickr.com/ ... /uploadr/file.js?rev=501

25th of March, 2009@12:08:13 PM
8 comments, permanent link to article

Comments

[7th of Aug, 2009 @ 02:06 PM]
Rajeev said:
Hi,
OnUnload I need a confirm box,as "continue? OK or Cancel". But Its not working ... I set confirm("Are you sure")...and when I press cancel,,the side bar closes...Please help///
[7th of Aug, 2009 @ 02:22 PM]
Rajeev said:
Hi,
OnUnload I need a confirm box,as "continue? OK or Cancel". But Its not working ... I set confirm("Are you sure")...and when I press cancel,,the side bar closes...Please help///
[7th of Aug, 2009 @ 02:22 PM]
Rajeev said:
Hi,
OnUnload I need a confirm box,as "continue? OK or Cancel". But Its not working ... I set confirm("Are you sure")...and when I press cancel,,the side bar closes...Please help///
[7th of Aug, 2009 @ 02:22 PM]
Rajeev said:
Hi,
OnUnload I need a confirm box,as "continue? OK or Cancel". But Its not working ... I set confirm("Are you sure")...and when I press cancel,,the side bar closes...Please help///
[29th of Aug, 2010 @ 04:50 AM]
http://www.livescribe.com/forums/member.php?u=8053&uz17=1 [url=http://www.livescribe.com/forums/member.php?u=8059&uz17=1]cialis[/url] <a href="http://www.livescribe.com/forums/member.php?u=8058&uz17=1">free viagra</a> <a href=http://www.livescribe.com/forums/member.php?u=8054&uz17=1>fioricet</a> [url="http://www.livescribe.com/forums/member.php?u=8060&uz17=1"]generic cialis[/url] [LINK http://www.livescribe.com/forums/member.php?u=8056&uz17=1]buy tramadol[/LINK] aebf
[30th of Aug, 2010 @ 06:11 AM]
http://www.livescribe.com/forums/member.php?u=8056&uz17=2 [url=http://www.livescribe.com/forums/member.php?u=8060&uz17=2]cheapest cialis[/url] <a href="http://www.livescribe.com/forums/member.php?u=8053&uz17=2">hydrocodone online</a> <a href=http://www.livescribe.com/forums/member.php?u=8058&uz17=2>viagra</a> [url="http://www.livescribe.com/forums/member.php?u=8054&uz17=2"]fioricet[/url] [LINK http://www.livescribe.com/forums/member.php?u=8055&uz17=2]diazepam online[/LINK] xkbf
[1st of Sep, 2010 @ 02:29 AM]
http://www.livescribe.com/forums/member.php?u=8059&uz17=3 [url=http://www.livescribe.com/forums/member.php?u=8053&uz17=3]hydrocodone[/url] <a href="http://www.livescribe.com/forums/member.php?u=8056&uz17=3">buy tramadol</a> <a href=http://www.livescribe.com/forums/member.php?u=8057&uz17=3>viagra</a> [url="http://www.livescribe.com/forums/member.php?u=8055&uz17=3"]diazepam online[/url] [LINK http://www.livescribe.com/forums/member.php?u=8058&uz17=3]viagra[/LINK] rnev
[2nd of Sep, 2010 @ 07:30 PM]
http://www.livescribe.com/forums/member.php?u=8054&uz17=4 [url=http://www.livescribe.com/forums/member.php?u=8057&uz17=4]cheap viagra[/url] <a href="http://www.livescribe.com/forums/member.php?u=8060&uz17=4">cheapest cialis</a> <a href=http://www.livescribe.com/forums/member.php?u=8056&uz17=4>buy tramadol</a> [url="http://www.livescribe.com/forums/member.php?u=8053&uz17=4"]hydrocodone online[/url] [LINK http://www.livescribe.com/forums/member.php?u=8055&uz17=4]diazepam online[/LINK] xowm

Check this if you are a human being. Thanks. (I'm trying to reduce my comment spam :-)

Comment

Server Grind [0.0072 seconds]