addeventlistener for click - Mozilla

This is a discussion on addeventlistener for click - Mozilla ; Hello everyone Smile 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 ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: addeventlistener for click

  1. addeventlistener for click

    Hello everyone Smile
    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

    http://forums.mozillazine.org/viewtopic.php?p=2704017 ,
    http://groups.google.com/group/mozil...f515bb2cd95a98
    http://groups.google.com/group/mozil...6e2b81432f55a9

    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 :-)

  2. Re: addeventlistener for click

    On May 8, 12:16 pm, newbiegalore wrote:
    > Hello everyone Smile
    > 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
    >
    > http://forums.mozillazine.org/viewto...rowse_thread/t...
    >
    > 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 :-)


    OK problem solved, jut a syntax error..

  3. Re: addeventlistener for click

    newbiegalore wrote:
    > On May 8, 12:16 pm, newbiegalore wrote:
    >> Hello everyone Smile
    >> 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
    >>
    >> http://forums.mozillazine.org/viewto...rowse_thread/t...
    >>
    >> 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 :-)

    >
    > OK problem solved, jut a syntax error..


    Wouldn't it be simpler to just use a history listener that listens for
    onHistoryGoBack? This is a terribly old link
    http://www.mozilla.org/projects/embe...mbedapi71.html
    and mdc has better stuff.

    Tom

  4. Re: addeventlistener for click

    On May 8, 6:34*pm, Tom wrote:
    > newbiegalore wrote:
    > > On May 8, 12:16 pm, newbiegalore wrote:
    > >> Hello everyone Smile
    > >> 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

    >
    > >>http://forums.mozillazine.org/viewto...ttp://groups.g.......

    >
    > >> 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 :-)

    >
    > > OK problem solved, jut a syntax error..

    >
    > Wouldn't it be simpler to just use a history listener that listens for
    > onHistoryGoBack? This is a terribly old linkhttp://www.mozilla.org/projects/embedding/embedapiref/embedapi71.html
    > and mdc has better stuff.
    >
    > Tom- Hide quoted text -
    >
    > - Show quoted text -


    Thanks Tom, yes you are right!

    -A

+ Reply to Thread