Navigation
Poll
Would you be an active poster if Ron's Guide had a message board?


Total Votes: 62
Comments: 18 — View
Past pollsPoll idea?
Rate Ron's Guide
Rate our resource at Bigwebmaster.com
Discuss Tutorial: Using parentNode 1 Comment
Comment by Hammerattack on Jun 25, 2006, 2:38 pm
If you put your javascript into the head of your html file, you'll get errors. Firefox complains that...

document.getElementById("child"Wink 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 "Laughingiv". You were probably expecting it to say "child". Replace "nodeName" with "id" in the script, and it will.

« Previous [ 1 ] Next »
Post a comment
Sorry, you must be a registered member to post comments.

If you would like to register, you can do so here.
If you already have an account, please login.