[thelist] window.onload (was Preload images)

Sam sam at sam-i-am.com
Thu Feb 7 10:53:01 CST 2002

> using window.onload, you can only call a single function and cannot pass
> arguments to it.  however, you can place it in an external javascript file,
> keeping the scripting separate from the html.  you can get around the
> restriction of only being able to call a single function and not being able
> to pass arguments by creating a wrapper function you call that does all your
> work for ya.

but don't forget to *append* your event handler, or you risk wiping out
whatever value was already there, see:

I've found this a really useful technique, particularly as I'm usually
writing scripts and templates, rather than building the pages
themselves, so I don't always have access to the body tag. However, I
recently ran into objections that this is code modifying code, and a Bad
Thing(tm). From the point of view of debugging and trying to make head
or tail of what a page is doing, it does complicate matters - so use
with caution, and only where really necessary.


More information about the thelist mailing list