New event listeners without disturbing old?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • optimistx

    New event listeners without disturbing old?

    I try to develope a bookmarklet, which hopefully can be activated on almost
    any http-page (i.e. from any server).
    The page can have unknown event handlers.
    The bookmarklet wants to add its own event handlers for the page without
    unnecessarily disturbing the original ones.

    The problem resembles the onload-event handling: if there is already one how
    to add another so that both handllers can do their work? ( this problem can
    be solved , but in this case this is not the problem.

    When playing with the FORK-framework some events could work without
    disturbing each other, but some other events obviously did not: if e.g.
    there was originally defined a 'click'-handler for the body and the
    bookmarklet defined its own for the same event, the original might stop
    working.

    Is there an easy way to solve this problem generally, without knowing how
    the original events are handled?

    The problem is more or less fun and hobby, not to be taken very seriously.
    Hopefully this would be fun for you too :).


  • Gregor Kofler

    #2
    Re: New event listeners without disturbing old?

    optimistx meinte:
    Is there an easy way to solve this problem generally, without knowing how
    the original events are handled?
    What's wrong with addEventListene r/attachEvent?

    Gregor


    --
    http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
    http://web.gregorkofler.com ::: meine JS-Spielwiese
    http://www.image2d.com ::: Bildagentur für den alpinen Raum

    Comment

    • optimistx

      #3
      Re: New event listeners without disturbing old?

      Gregor Kofler wrote:
      optimistx meinte:
      >
      >Is there an easy way to solve this problem generally, without
      >knowing how the original events are handled?
      >
      What's wrong with addEventListene r/attachEvent?
      >
      Gregor
      Good question! Nothing is wrong with them, but are they supposed not to
      prevent previously defined ('original') events from being handled? Might be
      that in my hasty preliminary tests some other things were disturbing the
      situation. (Also an embarrassinging error happened: I had two event handling
      functions on the same page with the same name... no wonder one of them
      stopped working.)
      This situation is like loading several different frameworks to the same
      page and hoping everyone of them would continue behaving nicely.


      Comment

      • Gregor Kofler

        #4
        Re: New event listeners without disturbing old?

        optimistx meinte:
        Gregor Kofler wrote:
        >What's wrong with addEventListene r/attachEvent?
        Good question! Nothing is wrong with them, but are they supposed not to
        prevent previously defined ('original') events from being handled?
        The *events* are always the same. And those methods are there, that
        several *listeners* can peacefully co-exist.
        This situation is like loading several different frameworks to the same
        page and hoping everyone of them would continue behaving nicely.
        Depends on the frameworks. But "normally" they can be combined without
        too many problems. At least as fas as event listening goes.

        Gregor


        --
        http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
        http://web.gregorkofler.com ::: meine JS-Spielwiese
        http://www.image2d.com ::: Bildagentur für den alpinen Raum

        Comment

        Working...