RobG wrote:
On Jan 25, 6:45 am, "windandwaves" <nfranc...@gmail.comwrote:
>does it matter if I write
var anchors = document.getElementsByTagName("A");
or
var anchors = document.getElementsByTagName("a");
No.
Since HTML tag names are not case sensitive, getElementsByTagName isn't
either. It's not specified that way, but it makes sense to be so.
>Or is there a better way to catch both <a hrefs and <A HREFS
In HTML, they are identical. But you might find:
var anchors = document.links;
is more appropriate.
<URL: http://www.w3.org/TR/DOM-Level-2-HTM...tml#ID-7068919 >
Actually, there *is* a difference!
I recently converted a set of documents to XHTML 1.1, and decided to
have the mime-type served up to all non-IE browsers as
application/xhtml+xml (with IE still getting text/html).
Well, the use of capitalized values in my getElementsByTagName() (as
well as everywhere else) ceased to work in all non-IE browsers,
especially when comparing values (==). When I changed them to lowercase,
the reverse happened (non-IE browsers suddenly worked, IE didn’t).
The trick for me was to add a .toLowerCase() to every comparison. For
example, this method:
if (item.nodeName.toLowerCase() == "a") {}
worked flawlessly across both IE and non-IE browsers.
When you get the server to set a mime-type of application/xhtml+xml,
non-IE browsers always interpret elements as they are typed (if you use
uppercase in your HTML, the JS will need uppercase references... and all
my XHTML is all in lowercase).
Even though IE doesn’t get this mime-type (it is still served up as
traditional text/html), the presence of the DOCTYPE as the first item
(the XML declaration simply isn’t added in by the server-side script)
causes IE to go into standards-compliant mode, and for some reason the
JS implemented in IE will always assume an element to be uppercase,
irregardless of how it is actually typed in the web page.
Gotta love M$ to give us such a broken and badly designed browser! No
wonder I haven’t used it in five years (aside from ensuring the work I
do functions adequately with it). Vive lÃ* Firefox!
Cheers!
...Geshel
--
************************************************** *******************
My e-mail address is an automatically monitored spam honeypot. Do not
send e-mail there unless you wish to be reported as a spammer. Please
send e-mail to my first name at my last name dot org.
************************************************** *******************