View Single Post
Old 11-11-2012, 08:48 PM   PM User | #8
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,043
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by felgall View Post
The only thing wrong with either of those is that JavaScript is supposed to go at the bottom of the body. Placing it in the head (with very few exceptions where you don't want the page to load) is obsolete.
This is an example where placing the script in the <head> is perfectly proper. Although right ahead of the </body> tag is to be preferred, there is no real reason why scripts (especially small scripts such as this) cannot be placed in the <head>.

Nile - My solution and yours are effectively the same, but I did not see your post before I submitted mine. Both ought to work.
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote