Simple Javascript - Document Acces - nodeName

Hi, little problem understanding this from the book…
Supposedly I’d suppose to get an alert dialog displaying the tag name of “a”…

Instead i get nothing… Any ideas were I’ve gone wrong?

thx


<html>
<body>

<script type="text/javascript">
var target = document.getElementById("berger");
alert(target.nodeName);	
</script>

<a id="berger" href="test">test</a>

</body>
</html>

crap i think i just posted this in the wrong section of the forum… if a moderator could move it that would be great…

sorry

i’ve seeked help elsewhere. Here was the issue
The javascript was being run before the HTML was loaded.

The book states a fix for this at the beginning, i guess i should have used that before testing my code.

So how did you do it I guess it has something to do with init function and the core.start

can you show me what code you used in the final please