Originally Posted by felgall
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.