Your trying to ask your script to search for 2 elements which don't exist on the page yet, when using document.getElementById() it either needs to be loaded within window.onload() or before the ending </body> element on the page. See the examples below
Loaded within window.onload()
Code JavaScript:
window.onload = function() {
loaded = true;
doPoll();
onAvailable('google', function(){
document.getElementById('google').onclick = function() {alert(this.id);};
});
onAvailable('yahoo', function(){
document.getElementById('yahoo').onclick = function() {alert(this.id);};
});
};
Loaded before the ending </body> element
HTML Code:
<script type="text/javascript">
onAvailable('google', function(){
document.getElementById('google').onclick = function() {alert(this.id);};
});
onAvailable('yahoo', function(){
document.getElementById('yahoo').onclick = function() {alert(this.id);};
});
</script>
</body>
Bookmarks