[Javascript] dom/javascript question regarding Internet Explorer
Lee Bettridge
lbettridge at twowaytv.co.uk
Fri Jul 20 04:30:07 CDT 2007
I want to copy the contents of the <title></title> tag in an html
document and write this elsewhere in the doc when it loads.
The following works in Firefox but not in ie, could anyone point out why
and maybe suggest an alternative please.
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>User Guide</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script src="./toc.js"></script>
</head>
<body onload="toc();" id="body">
<div class="document_header" id="document_header"></div>
</body>
</head>
</html>
JAVASCRIPT
var title = document.getElementsByTagName("TITLE").item(0);
var str_title = title.firstChild.data;
var obj = document.getElementById("document_header");
while(obj.hasChildNodes()) obj.removeChild(obj.childNodes[0]);
obj.appendChild(document.createTextNode(str_title));
________________________________________________________
Two Way TV is the trading name of Two Way Media Ltd
Company Number: 4904168
More information about the Javascript
mailing list