Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #19326

Re: Accessing image property in IE when there's a period in the html ID?

Message-ID <1411375.u70iIU05oh@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2013-04-18 11:06 +0200
Subject Re: Accessing image property in IE when there's a period in the html ID?
Newsgroups comp.lang.javascript
References <kkn90j$nuv$1@news.albasani.net> <kknb7u$rnl$1@news.albasani.net>

Show all headers | View raw


Stefan Weiss wrote:

> On 2013-04-18 00:50, Tuxedo wrote:
>> Accessing it's src value in FF and other non-IE browsers may be done by:
>> alert(document.images["0010.0"].src);
>> 
>> Or if passed as an argument:
>> function bla(ID){
>> alert(document.images[ID].src);

Should be “id”, so as not to give the false impression of a constant or 
constructor.

>> }
>> bla("0010.0");
> 
> Why are you using document.images? You got the id, so use
> document.getElementById().

“document.images[…]” is probably faster than document.getElementById(…), not 
operating on as large an HTMLCollection.  It is also more precise and self-
descriptive.  

However, using an ID (“id” attribute value of “img” elements) instead of a 
name (“name” attribute value of “img” elements) is not backwards-compatible 
to DOM Level 0.

<http://docs.oracle.com/cd/E19957-01/816-6408-10/document.htm#1226315>
<http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-90379117>
<http://www.w3.org/TR/2012/CR-html5-20121217/dom.html#the-id-attribute>
<http://www.w3.org/TR/2012/CR-html5-20121217/dom.html#dom-document-images>

-- 
PointedEars

Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Accessing image property in IE when there's a period in the html ID? Tuxedo <tuxedo@mailinator.com> - 2013-04-18 00:50 +0200
  Re: Accessing image property in IE when there's a period in the html ID? Stefan Weiss <krewecherl@gmail.com> - 2013-04-18 01:29 +0200
    Re: Accessing image property in IE when there's a period in the html ID? "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2013-04-18 07:53 +0300
      Re: Accessing image property in IE when there's a period in the html ID? Stefan Weiss <krewecherl@gmail.com> - 2013-04-18 10:07 +0200
    Re: Accessing image property in IE when there's a period in the html ID? Tuxedo <tuxedo@mailinator.com> - 2013-04-18 08:39 +0200
    Re: Accessing image property in IE when there's a period in the html ID? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-04-18 11:06 +0200
      Re: Accessing image property in IE when there's a period in the html ID? "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2013-04-18 13:05 +0300
        Re: Accessing image property in IE when there's a period in the html ID? Andrew Poulos <ap_prog@hotmail.com> - 2013-04-18 20:21 +1000
        Re: Accessing image property in IE when there's a period in the html ID? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-04-18 12:39 +0200
          Re: Accessing image property in IE when there's a period in the html ID? Stefan Weiss <krewecherl@gmail.com> - 2013-04-18 16:38 +0200
            Re: Accessing image property in IE when there's a period in the html ID? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-04-19 01:25 +0200
              Re: Accessing image property in IE when there's a period in the html ID? Stefan Weiss <krewecherl@gmail.com> - 2013-04-19 19:40 +0200
                Re: Accessing image property in IE when there's a period in the html ID? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-04-19 19:52 +0200
        Re: Accessing image property in IE when there's a period in the html ID? "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2013-04-18 13:56 +0300
          Re: Accessing image property in IE when there's a period in the html ID? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-04-18 13:19 +0200

csiph-web