I get this a lot in a web application I've written for my company. Just
about EVERY page is some sort of data entry page, and (of course) everyone
wants the focus placed when the page loads.
I get around this by putting all of my javascript at the END of the page,
rather than in the <head> section, with the last line of script being the
..focus() line. That way, the page and all of its elements have completely
loaded before any client-side instructions are executed. This has the added
benefit of cutting way way back on "object required" and "not found" errors.
Some of the pages are huge, and involve mind-numbingly lengthy client-side
validation scripts. When I inherited the application, those scripts were
scattered all over the page. What I do now is declare a server-side array
at the top of the page, adding the client-side function code to it as the
page builds (each element gets a function or discrete instruction), then as
a last step write the SCRIPT tag, loop the array writing all the javascript,
then close the script.
- Wm "It may be wrong but you wanted it fast" Morris