473,320 Members | 2,035 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,320 software developers and data experts.

var anchors = document.getElementsByTagName("A");

does it matter if I write

var anchors = document.getElementsByTagName("A");

or

var anchors = document.getElementsByTagName("a");

Or is there a better way to catch both <a hrefs and <A HREFS

Thanks a million

Nicolaas

Jan 24 '07 #1
3 16501


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 >
--
Rob

Jan 24 '07 #2


On Jan 25, 10:07 am, "RobG" <r...@iinet.net.auwrote:
Thanks Rob G. Your help is always extremely appreciated!

Jan 24 '07 #3
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.
************************************************** *******************
Jan 25 '07 #4

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

Similar topics

3
by: Phil | last post by:
Hi everybody, I am a XSLT beginner and the following problem really makes me crazy ! I have a main "contacts.xml" document which contains references to several contact data XML files. My aim...
0
by: JD | last post by:
While reading through the "shortcuts" topic in the help, I saw that there's a "Format Document" option - CTRL+K, CTRL+D. Cool... so I go into a .cs source file (this is a winforms project) and hit...
0
by: Pieter Linden | last post by:
I found this code posted by FredG (thanks Fred!) This will cycle through all your reports. Public Sub GetRecordSource() ' Print out the RecordSource for each report. Dim doc As Document Dim...
2
by: Claus - Arcolutions | last post by:
I got a word document as a stream, and I want to get the text from the word document. But I cant seem to find anything to use for that purpose. The "Microsoft office ?.object" com reference, only...
8
by: Just Me | last post by:
1)How can I find the folders like "My Recent Document", "Desktop", "My Pictures",... if I want to store a file there? 2) How can I find the icon for those files if I want to display it? ...
1
by: gslim | last post by:
I am trying to implement the busybox sample from // From Mark Wagner // http://blogs.crsw.com/mark/articles/642.aspx When I get to this line I get an access denied error. Could someone give me...
2
by: Bryan | last post by:
Hello all, Can anyone explain when one should use the "document" object and when one should use the "this" object? Also, is the "self" object the same as the "document" or "this" object?
0
by: =?Utf-8?B?QXR1bA==?= | last post by:
When .Net 1.0 webservice (VS2003) generates a wsdl - <wsdl:binding name="TestSoap" type="tns:TestSoap"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/(note:...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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: 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)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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.