Le 11/7/08 7:44 AM,
ha******@gmail.com a écrit :
Hi, all
I found I can get the img element named with "image1" in a html by
using "document.image1" with javascript.
It's the old way to get elements, and here : image
But the element must have a 'name' and not only an 'id'.
Take care if you have only ids that only IE will run with this feature.
<img name="image1" id="image1" src blah >
When a browser reads an html file its javascript engine parses the code,
building all the JS trees (the old ones and the DOM).
JS trees :
- document.images
- document.forms (and for each form : document.forms[i].elements)
- document.anchors
- document.links
- ...
It's very convenient because
I don't need to use the long method like getElementByName etc.
usually you have to do :
document.images['image1']
this approach is the part of the DOM?
Absolutely not ! the DOM is the DOM.
You get or set elements via the Document Model Objects
I think javascript DOM functions have been added with version 1.5
I have checked the DOM specification, but found nothing.
Of course :
most of the time it is forbidden to give a 'name' to the elements,
so the DOM doesn't know 'name', or almost not
document.getElementsByName('aName');
will return the collection of elements named 'aName'.
Can somebody give me clue? Thanks.
search about JavaScript 1.2
--
sm