473,394 Members | 1,802 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,394 software developers and data experts.

Real object listener: solved

VK
Anyone who's interested.
I implemented my own way to always get the right registered event
listener in case of nested elements *without* using intrinsic handlers
(so say you want to keep your HTML/XML and scripting completely
separate).

In FF you do it by listening events on their phase 1 (up -> down).

In IE you do it by extending event attacher with the missing (by my
opinion) property: boolean isRegisteredListener.

It's not a product, I just was working on it during my other project.

May look at the test here:

<http://www.geocities.com/schools_ring/RealTarget.html>

Jul 23 '05 #1
4 1383
On 14/07/2005 15:43, VK wrote:

[snip]
<http://www.geocities.com/schools_ring/RealTarget.html>


Or you avoid the attachEvent method and then use the this operator, instead.

Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.
Jul 23 '05 #2
VK
> Or you avoid the attachEvent method and then use the this operator, instead.

Well, in my situation it's a unpredefined scope of handlers called by a
single event, so addEventListener/attachEvent was kind of a must.

But yes, the universal obj.onevent = ref would kill a good part of
these if's-else's (I hate them actually).

Jul 23 '05 #3
ASM
VK wrote:
Anyone who's interested.

May look at the test here:

<http://www.geocities.com/schools_ring/RealTarget.html>


doesn't work with my IE5.2 (Mac)

"no matter where inside that cell do you click."
no with Safari (in right cell : support clic only if is in green div)

Do not understand so much complication

in the case of your example
(tested in my IE5.2, Safari, FF10.4, iCab3.0)

function highlgt(){
var T = document.getElementsByTagName('TD');
for(var i=0;i<T.length;i++)
if(T[i].id)
T[i].onclick=
Function('this.className=this.className==\'cellHig h\'?\'cellLow\':\'cellHigh\';');
}
onload = highlgt;

--
Stephane Moriaux et son [moins] vieux Mac
Jul 23 '05 #4
On 14/07/2005 18:33, VK wrote:
Or you avoid the attachEvent method and then use the this operator,
instead.


Well, in my situation it's a unpredefined scope of handlers called by a
single event, so addEventListener/attachEvent was kind of a must.


If you mean that you may have more than one listener on a single
element, then you still don't need the attachEvent method. It can be
emulated, which also adds support for other browsers with an event model
but no addEventListener method, and in doing so, you can get much better
behaviour.

[snip]

Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.
Jul 23 '05 #5

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

Similar topics

7
by: Morten Aune Lyrstad | last post by:
Here's the deal: I'm looping through a collection of listener class objects like this: (illustration code only) AClass::ThrowEvent() { for (int i = 0; i < numListeners; i++) {...
2
by: Anson | last post by:
Hello, I would like to clarify something about Remoting Object in .NET. Knowing from MSDN that in order for Remote Object to work, I need 3 components. a) RemotableType object, just like a...
1
by: Armin Zingler | last post by:
Hi, I add a TraceListener to Debug.Listeners. After that I use Debug.writeline. Problem: Nothing arrives at the listener. Code: Dim ts As New TraceStream Debug.Listeners.Add(New...
1
by: James Mills | last post by:
On 10/7/08, James Mills <prologic@shortcircuit.net.auwrote: Out of curiosity I modifed my bench marking tool for my event/component library (pymills) and here are the results: ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.