newbiegalore
Programmer
Hello everyone
I am writing a toolbar for firefox and want to detect when the back
button is pressed. I tried searching for answers but did not find a
satisfactory (simple) one. I have however not looked into using DOM
inspector as yet.
I am thinking of writing a listener for a mouse click, this is a poor
solution but works nonetheless, of course I do realize that a user
could go "back" without clicking too.
I have successfully used an event listener for detecting page loads
and tried to write the click listener based on that.
window.addEventListener( "click", JAAL-KeyPress, false);
function JAAL-KeyPress(e) {
examplePageLoad(e);
alert('clicked');
}
I also tried using window.addEventListener( "click", function () {
gBrowser.addEventListener("click", JAAL-KeyPress, true);
}, false);
I have also tried document.onclick = JAAL-KeyPress; too but these did
not work. Can someone please let me have a pointer about what may be
wrong. I suspect its something with the syntax, since I'm a novice
with extension dev and JS. I have parsed MDC for addevenlistener and
did find an example with 'click' listener but my code is similar to
that one but it does not work. In fact using this code screws up the
page-load listener functionality. I have searched the following forums
and some examples are present at
,
again my code seems similar to them..alas!!
I'd really appreciate any pointers about how to solve this problem,
Thanks
-A
PS: If someone could also direct me to a way to specifically capture a
click on the back button it would be super
I am writing a toolbar for firefox and want to detect when the back
button is pressed. I tried searching for answers but did not find a
satisfactory (simple) one. I have however not looked into using DOM
inspector as yet.
I am thinking of writing a listener for a mouse click, this is a poor
solution but works nonetheless, of course I do realize that a user
could go "back" without clicking too.
I have successfully used an event listener for detecting page loads
and tried to write the click listener based on that.
window.addEventListener( "click", JAAL-KeyPress, false);
function JAAL-KeyPress(e) {
examplePageLoad(e);
alert('clicked');
}
I also tried using window.addEventListener( "click", function () {
gBrowser.addEventListener("click", JAAL-KeyPress, true);
}, false);
I have also tried document.onclick = JAAL-KeyPress; too but these did
not work. Can someone please let me have a pointer about what may be
wrong. I suspect its something with the syntax, since I'm a novice
with extension dev and JS. I have parsed MDC for addevenlistener and
did find an example with 'click' listener but my code is similar to
that one but it does not work. In fact using this code screws up the
page-load listener functionality. I have searched the following forums
and some examples are present at
,
again my code seems similar to them..alas!!
I'd really appreciate any pointers about how to solve this problem,
Thanks
-A
PS: If someone could also direct me to a way to specifically capture a
click on the back button it would be super