469,921 Members | 2,183 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,921 developers. It's quick & easy.

3 problems. All IE6. Bubbling. Source Order. Repeating

I tested the following script in Konqueror 3, Safari 3, Firefox 2 and
Opera 9. All browsers work as expected and all browsers are exactly
the same in there results. I have 3 peculiar problems I hope I
commented well on the following pastebin.

http://dpaste.com/hold/26276/

I did not include the HTML but did include the snippet in which this
script deals with (at the tail end of the paste). I am still very new
in learning JavaScript so there might be something I am missing
entirely. I appreciate any help on these issues regarding IE6.

Thanks!
Nov 30 '07 #1
5 1051
vbgunz wrote:
this is funny. I scrolled back up in my current book "Wrox
Professional JavaScript" yesterday and as I was scrolling back down to
recapture my position, I came across something I already read. this
will sum up my confusion a bit (page 266).

"Event Handlers/Listeners
Events are certain actions performed either by the user or by the
browser itself. These events have names like click, load, and
mouseover. A function that is called in response to an event is called
an event handler (or, as the DOM describes it, an event listener). A
function responding to a click event is considered an onclick event
handler. Traditionally, event handlers are assigned in one of two
ways: in JavaScript or in HTML."

could this be why comp.lang.javascript seems to be so adamantly
against books for learning JS? heh, I thought it was interesting :)
Yes, it is. The author evidently has not understood that events, event
handlers and event listeners are always part of a AOM or DOM, and they also
have proven not to understand that the W3C DOM (which is misdirectingly
referred there as "the DOM") is by far not the only DOM available.

Just another book that can safely be recommended against. Thanks you for
mentioning it.
PointedEars
Dec 4 '07 #2
pr
vbgunz wrote:
I have one new question related to all of this. can you check to see
if an object has been assigned a *specific* listener/handler? I mean,
can you check if an object has say attachEvent('onclick', funcX)? I
really doubt it cause I had an idea and google couldn't help. heh,
this is probably old news or something but I'll say what I thought. I
figured to get the correct (or similar to all the rest) event object
in IE6, I could build a queue of parentNodes that contained the exact
same event. this way, I could swap out the originating event object in
the chain with the parentNode next in queue. probably makes no sense
and is probably the dumbest thing I could come up with but I thought
it was worth a shot.
You can use obj.getAttribute('onclick') or obj.onclick == f to determine
what code has been assigned using HTML or the DOM. Beware that IE may
return an anonymous function object (not text) in that getAttribute() call.

I'm pretty sure you can't determine which eventListeners you have added
to an object, but since your script would normally keep track of which
ones it registered, the question shouldn't arise.
Dec 4 '07 #3
Thomas 'PointedEars' Lahn wrote:
I noticed that you use the proprietary `window.onload' event handler
property. You should not do that; <body ... onload="listenerFunction()"is
more reliable.
this is something I promised to get to as soon as time permitted. I
thought you were referring to the infamous addLoadEvent method here.
but coming back, I am beginning to think you probably meant something
else? Anyhow, I knew of addLoadEvent but disregarded it in favor of
window.onload (so much simpler). I went back to the book in which I
first heard about addLoadEvent and tried to really figure it out. It
was an aha! moment for sure and I love it. is this what you were
referring too?

if so I understand it now and will definitely use it!

thank you for your time!
Dec 10 '07 #4
Thomas 'PointedEars' Lahn wrote:
vbgunz wrote:
Thomas 'PointedEars' Lahn wrote:
I noticed that you use the proprietary `window.onload' event handler
property. You should not do that; <body ... onload="listenerFunction()"is
more reliable.
this is something I promised to get to as soon as time permitted. I
thought you were referring to the infamous addLoadEvent method here.
but coming back, I am beginning to think you probably meant something
else?

I was referring to the code you provided, starting with the first line;
I don't see an addLoadEvent() method there, nor is one required.
Anyhow, I knew of addLoadEvent [...]

What are you talking about? There is no such predefined method in
the known host environments.
addLoadEvent is a function created by Simon Willison and here is the
birth page and explanation of it http://simonwillison.net/2004/May/26/addLoadEvent/
.. I first found out about this function through the Friends of Ed, DOM
Scripting book. I found window.onload = easier at the time. going back
to the book based on cause of what you mentioned, I now understand and
prefer this function over window.onload. this is what I thought you
meant. maybe not exactly known by the name of addLoadEvent *but*
something similar.

I usually nest all my code within window.onload. not exactly because I
need it but I find while learning it is the easiest way to test what I
am working on. If working with window.onload is not exactly wise, what
would you suggest? would you mind clearing up how best to work with
window.onload? e.g., addEventListener?
Dec 11 '07 #5
vbgunz wrote:
Thomas 'PointedEars' Lahn wrote:
>vbgunz wrote:
>>Thomas 'PointedEars' Lahn wrote:
I noticed that you use the proprietary `window.onload' event handler
property. You should not do that; <body ... onload="listenerFunction()"is
more reliable.
this is something I promised to get to as soon as time permitted. I
thought you were referring to the infamous addLoadEvent method here.
but coming back, I am beginning to think you probably meant something
else?
I was referring to the code you provided, starting with the first line;
I don't see an addLoadEvent() method there, nor is one required.
>>Anyhow, I knew of addLoadEvent [...]
What are you talking about? There is no such predefined method in
the known host environments.

addLoadEvent is a function created by Simon Willison and here is the
birth page and explanation of it http://simonwillison.net/2004/May/26/addLoadEvent/
Apparently he's one of the those who don't understand that this approach is
inherently unreliable, needlessly. I am disappointed to see PPK supporting
the abolishment of intrinsic event handler attributes in favor of this
approach as I got the impression that his other contributions tell of a more
thorough thinking regarding client-side Web development.
would you mind clearing up how best to work with
window.onload? e.g., addEventListener?
Neither of those. The intrinsic `onload' event handler *attribute* of the
`body' element is always the best bet.
PointedEars
--
"Use any version of Microsoft Frontpage to create your site. (This won't
prevent people from viewing your source, but no one will want to steal it.)"
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Dec 11 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

33 posts views Thread by Jim Cobban | last post: by
7 posts views Thread by Mr. Mountain | last post: by
3 posts views Thread by Nathan Sokalski | last post: by
7 posts views Thread by comzy | last post: by
1 post views Thread by Roffers | last post: by
3 posts views Thread by Jason Madison | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.