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

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 1156
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

33
by: Jim Cobban | last post by:
I cannot get Netscape 4.79 to properly display the ordered list in the following fragment. <P>Get a specific portion of the date. Depending upon the value of index: <ol start=0> <li>complete...
7
by: Mr. Mountain | last post by:
In the following code I simulate work being done on different threads by sleeping a couple methods for about 40 ms. However, some of these methods that should finish in about 40 -80 ms take as long...
2
by: Brian | last post by:
NOTE ALSO POSTED IN microsoft.public.dotnet.framework.aspnet.buildingcontrols I have solved most of my Server Control Collection property issues. I wrote an HTML page that describes all of the...
3
by: Nathan Sokalski | last post by:
I have three LinkButtons in the HeaderTemplate of my DataList (I use them to let the user determine what to sort the list by). I am assuming that the event will be bubbled to the ItemCommand event...
7
by: comzy | last post by:
I have created an event bubbling for my pager control which is used for implementing paging in data grid. Althoug it worked very fine in .NET 1.1 it is throwing the following error after i migrated...
1
by: Roffers | last post by:
Okay I have a parent page, we'll call it parent.aspx and it holds the following two user controls <uc1:Box1 id="Box1" runat="server"></uc1:Box1<----THIS CONTAINS A DROP DOWN LIST <br>...
3
by: Jason Madison | last post by:
My SP1 install seemed to want to keep repeating the install. I spent 4 hours running the install, then it ran again (I got the message up saying it had finished, then it started again). I didn't...
2
by: tonydspaniard | last post by:
Hi there all, Using prototype.js I render a flash movie within a DIV dynamically and then I try to attach some events in order to maintain focus on main window cuz is responsible of event handling...
2
by: alhalayqa | last post by:
hi, in MSIE, you can attach onclick event to both anchor and document objects. here is some code : document.onclick = function() {alert('document clicked ...'); } <a href= " " ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.