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


Groups > comp.lang.javascript > #16251 > unrolled thread

document.elementname vs document.getElementById("id")

Started byDenis McMahon <denismfmcmahon@gmail.com>
First post2012-09-29 18:15 +0000
Last post2012-09-30 20:10 +0100
Articles 3 on this page of 23 — 8 participants

Back to article view | Back to comp.lang.javascript


Contents

  document.elementname vs document.getElementById("id") Denis McMahon <denismfmcmahon@gmail.com> - 2012-09-29 18:15 +0000
    Re: document.elementname vs document.getElementById("id") Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-29 22:17 +0200
    Re: document.elementname vs document.getElementById("id") dann90038@gmail.com - 2012-09-29 16:21 -0700
    Re: document.elementname vs document.getElementById("id") "J.R." <groups_jr-1@yahoo.com.br> - 2012-09-29 23:20 -0300
      Re: document.elementname vs document.getElementById("id") "J.R." <groups_jr-1@yahoo.com.br> - 2012-09-29 19:53 -0700
      Re: document.elementname vs document.getElementById("id") "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-09-30 11:02 +0300
        Re: document.elementname vs document.getElementById("id") Denis McMahon <denismfmcmahon@gmail.com> - 2012-09-30 13:10 +0000
        Re: document.elementname vs document.getElementById("id") Denis McMahon <denismfmcmahon@gmail.com> - 2012-09-30 13:14 +0000
          Re: document.elementname vs document.getElementById("id") "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-09-30 17:20 +0300
            Re: document.elementname vs document.getElementById("id") Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2012-09-30 21:09 +0200
              Re: document.elementname vs document.getElementById("id") "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-09-30 22:28 +0300
                Re: document.elementname vs document.getElementById("id") Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2012-09-30 21:53 +0200
              Re: document.elementname vs document.getElementById("id") Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-30 21:53 +0200
            Re: document.elementname vs document.getElementById("id") Denis McMahon <denismfmcmahon@gmail.com> - 2012-09-30 22:07 +0000
              Re: document.elementname vs document.getElementById("id") "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-10-01 06:23 +0300
                Re: document.elementname vs document.getElementById("id") Denis McMahon <denismfmcmahon@gmail.com> - 2012-10-01 08:11 +0000
                  Re: document.elementname vs document.getElementById("id") Stefan Weiss <krewecherl@gmail.com> - 2012-10-01 11:25 +0200
        Re: document.elementname vs document.getElementById("id") "J.R." <groups_jr-1@yahoo.com.br> - 2012-09-30 15:10 -0300
          Re: document.elementname vs document.getElementById("id") Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-30 20:43 +0200
      Re: document.elementname vs document.getElementById("id") Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-30 12:22 +0200
        Re: document.elementname vs document.getElementById("id") "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-09-30 13:44 +0300
          Re: document.elementname vs document.getElementById("id") Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-30 13:46 +0200
    Re: document.elementname vs document.getElementById("id") Dr J R Stockton <reply1239@merlyn.demon.co.uk.invalid> - 2012-09-30 20:10 +0100

Page 2 of 2 — ← Prev page 1 [2]


#16267

From"Jukka K. Korpela" <jkorpela@cs.tut.fi>
Date2012-09-30 13:44 +0300
Message-ID<k497qb$p60$1@dont-email.me>
In reply to#16266
2012-09-30 13:22, Thomas 'PointedEars' Lahn wrote:

>> <http://www.w3.org/TR/xhtml1/diffs.html>
> Nothing there supports your argument.  What is stated there instead is that
> the `id' attribute is of*type*  ID in XHTML 1.0, as opposed to HTML 4.01
> where it is of type NAME

As usual, the resident troll gets things all wrong in his eagerness to 
lecture pointlessly on marginal or completely off-topic issues that he 
has digested rather poorly. Surely if you read just the infamous 
Appendix C, and maybe the sloppy wording in HTML 4.01 spec prose, you 
might get such fancy ideas. But the HTML 4.01 Document Type Definitions, 
which are all that matters regarding attribute type defined per the 
spec, say:

<!ENTITY % coreattrs
  "id          ID             #IMPLIED  -- document-wide unique id --

-- 
Yucca, http://www.cs.tut.fi/~jkorpela/

[toc] | [prev] | [next] | [standalone]


#16268

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2012-09-30 13:46 +0200
Message-ID<149916666.oqrE2mbPsr@PointedEars.de>
In reply to#16267
Jukka K. Korpela wrote:

> 2012-09-30 13:22, Thomas 'PointedEars' Lahn wrote:
>>> <http://www.w3.org/TR/xhtml1/diffs.html>
>> Nothing there supports your argument.  What is stated there instead is
>> that the `id' attribute is of*type*  ID in XHTML 1.0, as opposed to HTML
>> 4.01 where it is of type NAME
> 
> [flame bait]  But the HTML 4.01 Document Type Definitions, which are
> all that matters regarding attribute type defined per the spec,

Wrong.  Because the DTDs are insufficient to define HTML, particularly with 
regard to the type of an attribute, the prose of the Specification is 
relevant as well.

> say:
> 
> <!ENTITY % coreattrs
>   "id          ID             #IMPLIED  -- document-wide unique id --

I stand corrected here, though.  However, contrary to João's statement, 
XHTML does _not_ mandate an `id' attribute instead of a `name' attribute, 
which was my point there (which was deliberately not quoted by the previous 
poster).

What also is not correct is my statement that every HTML 4.01 element may 
have an `id' attribute.  Although it is one of the core attributes, the 
BASE, HEAD, HTML, META, SCRIPT, STYLE, and TITLE elements do not have an 
`id' attribute declared in any variant of HTML 4.01.


PointedEars
-- 
Sometimes, what you learn is wrong. If those wrong ideas are close to the 
root of the knowledge tree you build on a particular subject, pruning the 
bad branches can sometimes cause the whole tree to collapse.
  -- Mike Duffy in cljs, <news:Xns9FB6521286DB8invalidcom@94.75.214.39>

[toc] | [prev] | [next] | [standalone]


#16289

FromDr J R Stockton <reply1239@merlyn.demon.co.uk.invalid>
Date2012-09-30 20:10 +0100
Message-ID<Vwud0QT0kJaQFw6w@invalid.uk.co.demon.merlyn.invalid>
In reply to#16251
In comp.lang.javascript message <k47drn$q7j$1@dont-email.me>, Sat, 29
Sep 2012 18:15:19, Denis McMahon <denismfmcmahon@gmail.com> posted:

>I'm pretty certain that using document.getElementById("id") is better
>than using document.elementname, but at the moment I'm having trouble
>pointing to any sort of authoritative reference for this.

An ID is required to be unique; but it is not guaranteed to be unique.

But if an element of the DOM tree is addressed by such as
document.body.branch.branch.leaf, that may be unique, on the basis that
attempting to add a second branch as sibling to a branch of the same
name either displaces the first branch or fails to add the second??  I
do not know.

That method has an advantage if there is a need to duplicate parts of
the DOM tree, such as forms.  I cannot recall how it is now done in
detail, but my page   holidays.htm   is an example; the material for the
right and left sides of the Atlantic differs only in the data provided,
and both can be displayed at once.

-- 
 (c) John Stockton, nr London, UK.  For Mail, see Home Page.  Turnpike, WinXP.
 Web  <http://www.merlyn.demon.co.uk/> - FAQ-type topics, acronyms, and links.
 Command-prompt MiniTrue is useful for viewing/searching/altering files. Free,
 DOS/Win/UNIX now 2.0.6; see <URL:http://www.merlyn.demon.co.uk/pc-links.htm>.

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.javascript


csiph-web