leftpeg
03-19-2004, 06:46 AM
The following code works OK (i.e the alert displays "Testing") in Mozilla 1.6 but generates a javascript error in IE6. Any pointers as to why would be appreciated.
<html>
<head>
<script language="javascript">
function testingDOM(){
var title;
title = document.getElementsByTagName("title");
alert(title.item(0).firstChild.nodeValue);
}
</script>
<title id="title">Testing</title>
</head>
<body>
<input type="button" value="click me" onClick="testingDOM()"/>
</body>
</html>
Also, if i change my function to the following
title = document.getElementById("title");
alert(title.firstChild.nodeValue);
it doesn't work at all.
Why is this?
Cheers
<html>
<head>
<script language="javascript">
function testingDOM(){
var title;
title = document.getElementsByTagName("title");
alert(title.item(0).firstChild.nodeValue);
}
</script>
<title id="title">Testing</title>
</head>
<body>
<input type="button" value="click me" onClick="testingDOM()"/>
</body>
</html>
Also, if i change my function to the following
title = document.getElementById("title");
alert(title.firstChild.nodeValue);
it doesn't work at all.
Why is this?
Cheers