Below are two snips of code for assigning an event handler for an onclick event. Version One works in IE, FF, Safari and Chrome. Version Two works in IE, Safari and Chrome, but not in FF. In Version One, I register the event handler in the markup. In Version Two, I use a newer, and supposedly more robust, method for registering the event handler.
Using firebug, it looks like the onclick event handler is not getting registered, though I cannot see why not. Any ideas appreciated. Thanks.
*************** Version One ******************************
< script type="text/javascript">
function handler()
{
// do something here
}
</script>
< a id="playerFive" class="player" onclick="handler()">
< img src="./images/speakerIcon25pxFFF4E0.png" alt=""/>
</a>
************************************************************
*************** Version Two ******************************
< script type="text/javascript">
function handler()
{
// do something here
}
</script>
< a id="playerFive" class="player">
< img src="./images/speakerIcon25pxFFF4E0.png" alt=""/>
</a>
< script type="text/javascript">
playerFive.onclick = handler;
< /script>
************************************************************
No comments:
Post a Comment