| Author |
JavaScript DOM Node-Traversal and the "Dreaded" Undefined Errors
|
Perry Terrance
Ranch Hand
Joined: Oct 02, 2009
Posts: 46
|
|
Hi All,
I am currently trying to convert some horrendous IE 7-specific JavaScript DOM codes into W3C-compliant DOM JavaScripts... Unfortunately, I've been hitting a lot of brickwalls where I try to translate an IE 7-specific JS-DOM property to a W3C compliant JS-DOM property - only to get the dreaded "undefined" error message in my Safari Error Console.
Take for example the following:
I've been wading through a lot of IE JS-DOM codes that end up giving me what Safari recognizes as HTMLFormElement node object. In Safari's Debug Mode, I see the HTMLFormElement node object is full of blank HTMLInputElement node objects. So I thought I could just do a HTMLFormElement.item(0), HTMLFormElement.item(1), etc... to select each of these HTMLInputElement node objects even though they are shown as blank in the debug window...
However - as soon as my JS hits HTMLFormElement.item(0) - the console says "undefined". Which doesn't make sense - cause HTMLFormElement.length = 100 (so there's definitely child-nodes in there.) At this point, I'm getting kind of lost on what to do, cause Safari is blatantly telling me HTMLFormElement exists - with length of 100, but I can't access even the 0-index item of it...
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56180
|
|
|
Did you mean HTMLFormElement.item(0) or HTMLFormElement.item[0]
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
Show some code.
Eric
|
 |
Perry Terrance
Ranch Hand
Joined: Oct 02, 2009
Posts: 46
|
|
Eric Pascarello wrote:Show some code.
Eric
myForm = HTMLFormElement
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
|
Are Bear mentioned, it should be () and not square brackets. It is a method on the DOM HTMLCollection.
|
 |
 |
|
|
subject: JavaScript DOM Node-Traversal and the "Dreaded" Undefined Errors
|
|
|