FF does not allow you to access DOM elements as javascript variables named by their ID.
You need to use getElementById
instead.
sje397
2010-10-14 06:24:38
FF does not allow you to access DOM elements as javascript variables named by their ID.
You need to use getElementById
instead.
in the last script block, playerFive
is never defined anywhere, you probably want
document.getElementById('playerFive').onclick=handler;
You can try this code
if(document.all)// For IE
{
document.getElementById('playerFive').attachEvent('onclick',handler);
}
else // For FF
{
document.getElementById('playerFive').addEventListener('click',handler,false);
}
<html>
<head>
<script type="text/javascript">
window.onload = function() {
var div = document.getElementById("dvClickMe");
if(div.attachEvent)
div.attachEvent('onclick', sayHello);
else
div.setAttribute('onclick', 'sayHello()');
}
function sayHello() { alert("Hello!"); }
</script>
</head>
<body>
<div id="dvClickMe">Click me!</div>
</body>
</html>
The above code is working on IE8 and FF 3.6.10