window.addEventListener("unload", alert('leaving page!'), false);
but this doesn't work! It simply displays an alert when the page has
loaded instead of when the user has requested to go somewhere else.
Does anyone have any suggestions?
cheers
You might try adding a listener for the "beforeunload" event rather
than just "unload".
thanks for the suggestion, but this also seems to do exactly the same
thing, do you have any other suggestions?
Cheers,
Ben
testChangedTabURL: function(){
//tests if the tab has been used to load a different URL
//set previousPage to whatever url you want to make sure the tab is
still loaded to, could be previously loaded page.
var previousPage = "WHATEVERURL.com";
var tabUrl = getBrowser().getBrowserAtIndex
(this.winIndex).currentURI.spec;
if(tabUrl != "undefined"){
if (tabUrl.indexOf(previousPage) >= 0) {
return false;
}else{
return true;
}
}else{
return false;
}
},
> _______________________________________________
> dev-extensions mailing list
> dev-ext...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-extensions
>