William Wedler

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromWilliam Wedler
ToMe
Subjectinitializing page before window.onload event fires
Date4 January 2006 20:33
Do you know of a good way to initialize a page before the
window.onloadevent fires? By initialize I am referring to calling a
function, init(),
that could put focus on a form text input or operate on some other part of
the DOM (like change style properties). If I use the window.onload action
listener, then init() does not get called until everything in the page,
including images and iframes, are loaded. Do you have any suggestions that
would call init() faster? I am trying to keep all of the javascript in the
head and in an externally linked .js file if possible.

Thanks,
William
FromMe
ToWilliam Wedler
SubjectRe: initializing page before window.onload event fires
Date4 January 2006 21:26
William,

> Do you know of a good way to initialize a page before the
> window.onloadevent fires? By initialize I am referring to calling a
> function, init(),

put this before the </body> tag:

<script type="text/javascript">
init();
</script>

That will run as soon as the page has loaded, without waiting for images or
iframes.


Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.