[Javascript] dom/javascript question regarding Internet Explorer

Lee Bettridge lbettridge at twowaytv.co.uk
Fri Jul 20 09:19:20 CDT 2007


This statement

var title = document.getElementsByTagName("TITLE").item(0);

in IE does not return on object but does in firefox, so I guess my
question is, in IE is the <title/> tag simply inaccessible or accessible
in some other Microsoft specific way ?
 

-----Original Message-----
From: javascript-bounces at LaTech.edu
[mailto:javascript-bounces at LaTech.edu] On Behalf Of Mike Dougherty
Sent: 20 July 2007 15:00
To: [JavaScript List]
Subject: Re: [Javascript] dom/javascript question regarding Internet
Explorer

On 7/20/07, Lee Bettridge <lbettridge at twowaytv.co.uk> wrote:
> var str_title = title.firstChild.data;  (error = Object Required)

are you sure title.firstChild is an object?  Are you sure that object
has a .data property?  Have you tried the .text property?  (which
might work for IE but not Fx)

maybe something like this?

if( title.firstChild ) {
  if( title.firstChild.data ){
    var str_title = title.firstChild.data;
  }
  else if(title.firstChild.text) {
    var str_title = title.firstChild.text;
    }
  else {
    var str_title = "Unknown Title";
  }
}
_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript
________________________________________________________
Two Way TV is the trading name of Two Way Media Ltd
Company Number: 4904168



More information about the Javascript mailing list