473,320 Members | 1,839 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 :).
Aug 21 '08 #1
3 1092
optimistx meinte:
Is there an easy way to solve this problem generally, without knowing how
the original events are handled?
What's wrong with addEventListener/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
Aug 21 '08 #2
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 addEventListener/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.
Aug 22 '08 #3
optimistx meinte:
Gregor Kofler wrote:
>What's wrong with addEventListener/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
Aug 22 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Amir Hardon | last post by:
I am dynamically adding rows to a table, and each row have a button which removes it. I have successfully implemented this for mozilla but I'm having troubles with IE, here is how I did it: ...
2
by: kj | last post by:
How does one trigger an event programmatically? I'm interested in how to do this in both the "Level 0" event model as well as in the DOM Level 2 event model. Thanks! kj -- NOTE: In my...
17
by: abs | last post by:
My element: <span onclick="alert('test')" id="mySpan">test</span> Let's say that I don't know what is in this span's onclick event. Is it possible to add another action to this element's onclick...
29
by: Patrick | last post by:
I have the following code, which regardless which works fine and logs to the EventViewer regardless of whether <processModel/> section of machine.config is set to username="SYSTEM" or "machine" ...
0
by: Kamilche | last post by:
''' event.py An event manager using publish/subscribe, and weakrefs. Any function can publish any event without registering it first, and any object can register interest in any event, even...
1
by: Marek Murin | last post by:
Hi all, I have created vb.net user control that has to be used by vb6 form. Everything goes well with putting the vb.net user control on the VB6 form until I want to receive any event from my...
0
by: Eniac | last post by:
Hello, I've started using Enterprise Library 2.0 recently and I've encountered a problem that seems to be ... well... undocumented :) Basically, when I set a Trace Listener (formatted event...
6
by: JeffDotNet | last post by:
Writing to a registered source in the Application event log I have an asp.net framework 2.0 app that I created on a winxp machine and now I am deploying it to IIS6 on a win server2003 machine. ...
2
by: meyousikmann | last post by:
This will be difficult to explain so bear with me. If anyone is familiar with Tibco Rendezvous and/or Microsoft Messaging, this may make more sense. I've created a hierarchy of objects that...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.