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

about document.image1

Hi, all

I found I can get the img element named with "image1" in a html by
using "document.image1" with javascript. It's very convenient because
I don't need to use the long method like getElementByName etc. I
wonder if this approach is the part of the DOM? I have checked the DOM
specification, but found nothing. Can somebody give me clue? Thanks.

Regards.
Nov 7 '08 #1
3 1273
ha******@gmail.com wrote on 07 nov 2008 in comp.lang.javascript:
I found I can get the img element named with "image1" in a html by
using "document.image1" with javascript. It's very convenient because
I don't need to use the long method like getElementByName etc. I
wonder if this approach is the part of the DOM? I have checked the DOM
specification, but found nothing. Can somebody give me clue? Thanks.
This is one of the crazy "features" of IE,
not cross-browser safe,
and ever a source of errors in IE itself.

Do not use it on open webpages.

Names are not unique in HTML, IDs are.
It is quite legal to give multiple images the same name.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Nov 7 '08 #2
ha******@gmail.com wrote:
I found I can get the img element named with "image1" in a html by
using "document.image1" with javascript. It's very convenient because
I don't need to use the long method like getElementByName etc. I
wonder if this approach is the part of the DOM?
It must be part of a DOM, otherwise it would not work. You should be asking
instead whether it is sanctioned by a Web standard. No, it is not. But see
below.
I have checked the DOM specification, but found nothing. Can somebody
give me clue? Thanks.
Read the ECMAScript Language Binding section of the W3C DOM Level 2 HTML
Specification on "objects that implement the HTMLDocument interface" and on
"objects that implement the HTMLCollection interface" to see that

document.images["image1"]

would be standards-compliant. It is also backwards-compatible because the
earliest implementations, that of NN 3.0 and IE 3.0 (the so-called "DOM
Level 0"), already supported it.
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Nov 7 '08 #3
SAM
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
Nov 7 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sandra Setz | last post by:
Hi, I was wondering if someone could explain to me what the difference is between the width propery of the picture property of an image and the width property of the image itself. I would...
3
by: Sandra Setz | last post by:
Hi, Is it possible to assign the Picture property of a picturebox to the Picture property of an image control? I use an invisble picturebox to make some changes to a picture, but I want to...
6
by: michaaal | last post by:
Is this the correct way to preload an image...? Var Image1 = new Image() ....And then when I'm ready to use the image I can do this...? Button1.src=Image1.src ....Or am I just telling...
5
by: Julia Briggs | last post by:
Is there a <a href="javasc... approach to switch between two images inside a div tag so it doesn't slightly flicker when clicked on, and transitions between images smoothly in Netscape? I can get...
0
by: Kylin | last post by:
I have a data list and bind it's datasource to a DataSet , about data item , I write a javascript that can open a custom window to show the page , but in dataitem ,I use this function , only get...
5
by: Nospam | last post by:
does anyone know if there is anything wrong with this code? <SCRIPT LANGUAGE="JavaScript">document.referrer.indexOf("http://www.example.com") != -1){ ...
3
by: rkhurana | last post by:
Hi I am writing a JSF application that uses some third party charts. While I can see the chart but the javascript that is supposed to calla function to update chart periodically has a problem. It...
2
by: tesa | last post by:
I am not able to figure out how to make this work. I am trying to create a hangman game. I am in a basic javascripting class. I am to only use very basic code as you can see. I am able to use any...
4
by: roadiee | last post by:
I am sure this must be common but I can't seem to find how to do it. I have a file structure as follows: php - getimages.php gallery - index.html - image1.jpg - image2.jpg -...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.