V
VK
I have this code failing to work in IE: getElementsByTagName doesn't
return elements from my JS namespace. What's wrong?
<html xmlns:js>
<head>
<title>Que</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<style type="text/css">
<!--
body { background-color: #FFFFFF}
@media all {
js\:link { font-style: italic; color: #0000FF; text-decoration:
underline; cursor: hand; cursor: pointer}
}
-->
</style>
<script type="text/javascript">
<!--
function normalizeLinks(){
var jsLink = document.getElementsByTagName('JS:LINK');
// The method above doesn't work with IE
// IE has some fancy twist I have to be reminded again
for (i=0; i<jsLink.length; i++) {
jsLink.title = '';
jsLink.style.fontStyle = 'normal';
}
}
if ('addEventListener' in self) {
self.addEventListener('load',normalizeLinks,false);
}
else {
self.attachEvent('onload',normalizeLinks);
}
//-->
</script>
</head>
<body>
<p>
<a href="http://www.mozilla.org/products/firefox/">Mozilla Firefox</a>
</p>
<p>
<js:link title="JavaScript function call..."
onclick="alert('Booh!')">JavaScript call 1</js:link>
</p>
<p>
<a href="http://www.microsoft.com/windows/ie/default.mspx">Microsoft
Internet Explorer</a>
</p>
<p>
<js:link title="JavaScript function call..." onclick="alert('Booh
again!')">JavaScript call 2</js:link>
</p>
<p>
<a href="http://browser.netscape.com/ns8/">Netscape Navigator</a>
</p>
<p>
<js:link title="JavaScript function call..." onclick="alert('Booh
again!')">JavaScript call 3</js:link>
</p>
</body>
</html>
return elements from my JS namespace. What's wrong?
<html xmlns:js>
<head>
<title>Que</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<style type="text/css">
<!--
body { background-color: #FFFFFF}
@media all {
js\:link { font-style: italic; color: #0000FF; text-decoration:
underline; cursor: hand; cursor: pointer}
}
-->
</style>
<script type="text/javascript">
<!--
function normalizeLinks(){
var jsLink = document.getElementsByTagName('JS:LINK');
// The method above doesn't work with IE
// IE has some fancy twist I have to be reminded again
for (i=0; i<jsLink.length; i++) {
jsLink.title = '';
jsLink.style.fontStyle = 'normal';
}
}
if ('addEventListener' in self) {
self.addEventListener('load',normalizeLinks,false);
}
else {
self.attachEvent('onload',normalizeLinks);
}
//-->
</script>
</head>
<body>
<p>
<a href="http://www.mozilla.org/products/firefox/">Mozilla Firefox</a>
</p>
<p>
<js:link title="JavaScript function call..."
onclick="alert('Booh!')">JavaScript call 1</js:link>
</p>
<p>
<a href="http://www.microsoft.com/windows/ie/default.mspx">Microsoft
Internet Explorer</a>
</p>
<p>
<js:link title="JavaScript function call..." onclick="alert('Booh
again!')">JavaScript call 2</js:link>
</p>
<p>
<a href="http://browser.netscape.com/ns8/">Netscape Navigator</a>
</p>
<p>
<js:link title="JavaScript function call..." onclick="alert('Booh
again!')">JavaScript call 3</js:link>
</p>
</body>
</html>