[thelist] Javascript methods playing up

Christian Heilmann codepo8 at gmail.com
Sun Sep 4 15:34:34 CDT 2005


> Hi guys,
> 
> Can anyone give me a rational explanation of why the following causes IE
> to choke?
> 
>     var pageTitle =
> document.getElementsByTagName('title')[0].firstChild.nodeValue;
> 
> It works perfectly in Firefox and Opera.

Well, logically the document title cannot have children, so it does
make a bit of sense.

document.getElementsByTagName('title')[0].text

works for all.

document.title is shorter though, and not illegal either.

-- 
Chris Heilmann 
Blog: http://www.wait-till-i.com
Writing: http://icant.co.uk/  
Binaries: http://www.onlinetools.org/


More information about the thelist mailing list