Cascading onclick event

D

Dylan Parry

Hi,

I'm not sure what the correct term for this is, but I want to have two
objects (say HTML divs) positioned absolutely one on top of the other,
with the lower of the two having an onclick event attached to it.

Now as you can guess, if I then click on where the top and bottom object
overlap, the top object intercepts the click and the onclick event for
the bottom object is never fired.

What I want to do is to have the even "cascade" with the top object
ignoring the click and letting the bottom one handle it. Is this
possible? Am I being too vague?

Cheers,
 
I

impaler

Dylan said:
Hi,

I'm not sure what the correct term for this is, but I want to have two
objects (say HTML divs) positioned absolutely one on top of the other,
with the lower of the two having an onclick event attached to it.

Now as you can guess, if I then click on where the top and bottom object
overlap, the top object intercepts the click and the onclick event for
the bottom object is never fired.

What I want to do is to have the even "cascade" with the top object
ignoring the click and letting the bottom one handle it. Is this
possible? Am I being too vague?

Cheers,

Try these:
http://www.quirksmode.org/js/events_order.html
http://www.webdevelopersjournal.com/articles/jsevents2/jsevents2.html

I'm not sure if you have your div inside the other div or just
positioned absolutely but if nested you can use eventbubbling.
 
D

Dylan Parry

Pondering the eternal question of "Hobnobs or Rich Tea?", impaler
finally proclaimed:

eventCapture() seems to be what I am looking for, but it only works in
IE. Is there an alternative that does something like that in FF et al?
I'm not sure if you have your div inside the other div or just
positioned absolutely but if nested you can use eventbubbling.

Unfortunately they're not, so bubbling isn't an option. If I do nest the
divs a whole other can of worms is opened :s
 
D

Dylan Parry

Pondering the eternal question of "Hobnobs or Rich Tea?", Dylan Parry
finally proclaimed:
eventCapture() seems to be what I am looking for, but it only works in
IE. Is there an alternative that does something like that in FF et al?

erm setCapture() I meant! :)
 
T

Thomas 'PointedEars' Lahn

Dylan said:
[...] impaler [wrote]:

eventCapture() seems to be what I am looking for, but it only works in
IE. Is there an alternative that does something like that in FF et al?

The code there is not only IE-specific, it is junk. Do not
trust this source. Read the specs about event flow instead,
then apply the specified interfaces.

<URL:http://www.w3.org/TR/DOM-Level-2-Events/events.html>


HTH

PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top