[Web4lib] Valid substitute for body onLoad()
Stephen Meyer
smeyer at library.wisc.edu
Tue Oct 31 09:27:00 EST 2006
In Jeremy Keith's book DOM Scripting, which provides a good introduction
to unobtrusive JavaScript, he recommends using Simon Willison's
addLoadEvent function as a method for removing event attributes from
your markup:
http://simon.incutio.com/archive/2004/05/26/addLoadEvent
It has two major advantages: first, you can use it to queue up multiple
events to run once the page loads; and second, it allows you to put in
place a number of checks to ensure that a js-based utility will function
properly before it tries to execute. It scales well and degrades gracefully.
-Steve
Robert Sullivan wrote:
> I have found an almost-pure CSS method method for drop down menus
> which works across browsers and validates, except that it uses a small
> piece of Javascript which is called by <body onLoad>.
>
> That won't pass the validator and since I don't speak Javascript I am
> looking for an alternative means of doing that. The site I saw this
> on:
>
> <http://www.projectseven.com/tutorials/navigation/auto_hide/index.htm>
>
> says you may replace that with a window.onload in the script file, but
> before I get in any deeper I am asking people who actually know what
> they're doing. :-)
>
--
Stephen Meyer
Library Application Developer
UW-Madison Libraries
312F Memorial Library
728 State St.
Madison, WI 53706
smeyer at library.wisc.edu
608-265-2844 (ph)
"Just don't let the human factor fail to be a factor at all."
- Andrew Bird, "Tables and Chairs"
More information about the Web4lib
mailing list