About KJS::HTMLCollection::getNamedItems

Vadim Plessky lucy-ples at mtu-net.ru
Fri Aug 16 06:56:49 BST 2002


On Thursday 15 August 2002 3:33 pm, Koos Vriezen wrote:
|  On Thu, 15 Aug 2002, David Faure wrote:
|  > On Thursday 15 August 2002 10:31, Koos Vriezen wrote:
|  > > Ok, tested on IE 6.0:
|  > >   <html><body onLoad='alert(""+document.myname.nodeName)'>
|  > >   <form name="myname">
|  > >     <input name="myname" type="text">
|  > >   </form>
|  > >   </body></html>
|  > > Message box shows FORM. With document.myname.myname.nodeName it shows
|  > > INPUT.
|  >
|  > This only proves that the site works, it doesn't explain why/how.
|  > What does alert(""+document.myname) show?
|  > And document.myname[0].nodeName, and with [1] ?
|  > (to see if it behaves as an array AND as a normal element too)
|  >
|  > > If I add another form with 'myname' as name, the alert box shows
|  > > 'undefined', without the 'nodeName' its '[Object]'
|  >
|  > So you get a list of two forms in that case....
|  >
|  > > It seems that no collection is returned when child/parent with the
|  > > same name occur.
|  >
|  > That's a VERY broad statement, which would need further testing with
|  > other kind of elements.
|
|  Blame email. Seems as appears/looks like. Just trying to find some logic.
|
|  > - From the above one could also conclude that "document.formname" first
|  > looks at forms (and returns only forms, if it found any). The reason I'm
|  > tempted to believe in this "exception" is that document.formname is
|  > already an exception: we (and IE) look for that before looking for JS
|  > properties that have been set in the document. What I mean is (with the
|  > above <form> tag assumed) : document.myname = 'foo';
|  > alert(document.myname);  << will still return the FORM object, not
|  > 'foo'. But this only happens with forms and images apparently. The other
|  > cases of document.myname lookup are done after the JS property lookup.
|
|  I think you're right. Did some tests, always come up with FORM.
|
|  On this example:
|    <html><body onLoad='alert(""+document.myname.length)'>
|      <form name="myname">
|        <input name="myname" type="text">
|    </form></body></html>
|  => 1

Should not this example be:

<html><body onLoad='alert(""+document.myname.length)'>
<form id="myname">
<input id="myname2" type="text">
</form></body></html>
???

actually, there are two points:
1) attr. 'name' is deprecated, 'id' should be used
2) valid HTML can't have two elements with same 'id'
I think we already had similar problem when IIRC Thorsten Schnebeck provided 
URL to not-working German banking site (advanced-bank.de?)

|
|  alert(""+document.myname)
|  => [Object]
|
|  alert(""+document.myname[0].nodeName)
|  => INPUT
|
|  document.myname[1].nodeName
|  => script error
|
|  Regards,
|
|  Koos

-- 

Vadim Plessky
http://kde2.newmail.ru  (English)
33 Window Decorations and 6 Widget Styles for KDE
http://kde2.newmail.ru/kde_themes.html
KDE mini-Themes
http://kde2.newmail.ru/themes/





More information about the kfm-devel mailing list