This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes setting DOM properties Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "setting DOM properties" Watch "setting DOM properties" New topic

setting DOM properties

Higgledy Smith
Ranch Hand

Joined: Mar 07, 2006
Posts: 192
I am reading JavaScript: A Beginner's Guide, Second Edition and stuck on setting DOM property (page 227)

The author specifically instructs the reader to set the the alinkColor property in a script in the head section of the html document. But this does not work. What does work is setting the alink property in the

Does anyone know why it is not working in the head section? I checked the book's eratta, but no mention this is an error.

Thank you.


Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60810

Because the document doesn't exist yet. Use an onload handler to delay execution until after the DOM exists.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
It is sorta covered in the JavaRanch Style Guide.
subject: setting DOM properties
Similar Threads
javascript import
How to check if textboxes are null
JavaScript function in HTML body
Submitting HTML forms to 2 different URLs
Help the body "onunload" attribute FAILS with AOL