If you put your javascript into the head of your html file, you'll get errors. Firefox complains that...
document.getElementById("child" has no properties
...while IE complains that...
Object Required
The reason for this is that both browsers run the javascript before the DOM is completely parsed. Here the author puts the script after the elements it accesses, so it's processed after that part of the DOM is parsed. In actual web programming, you'll probably keep most of your javascript in the head tags. In order to get this to work, you need to wrap the alert in a function, and call that function after the document is loaded. You do that by putting onLoad="FunctionName()" into the body tag.
Even after you do that, your alert will say "iv". You were probably expecting it to say "child". Replace "nodeName" with "id" in the script, and it will.