Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] Onload event handlers for Safari
- From: nick at nickfitz.co.uk (Nick Fitzsimons)
- Subject: [Javascript] Onload event handlers for Safari
- Date: Tue Aug 29 11:34:24 2006
On 29 Aug 2006, at 16:46, Guillaume wrote: > I've come across this link apparently solving a long time problem > with onload event handlers for Safari... > > Reading articles about the onload event handlers for Safari, it > seems this browser behaves differently than Ie and Mozilla... > Here's a ressource that might help us on Den Edwards's site in an > article called: window.onload (again) > http://dean.edwards.name/weblog/2006/06/again/ > Safari handles onload perfectly well. Dean's article is about a different problem: the fact that, in _all_ browsers, onload only fires after all of the contents of the page have loaded. This means that, if (for example) you have images on a page, the onload event only fires when all of the images have been downloaded, which can take a while if there are lots of them, they are very large, or the user is on a slow connection. If you are using unobtrusive JavaScript to attach event handlers to elements on the page when the onload event fires, it is thus possible that the user will try to interact with the page before the onload event has fired, which is before your user interface has been activated. What Dean's (and others') technique does is allow one to start one's script when the page has been _parsed_ into a DOM, which is not the same thing as when it has _loaded_. This means that (assuming you don't try to do too much) you can get all your initialisation in place before the page is displayed to the user, and long before the onload event fires. It's a useful technique which handles one of the most important problems in DOM scripting (in fact, we discussed it at some length over a year ago at a get-together in London [1] which led to the founding of the Web Standards Project's DOM Scripting Task Force [2]). But it shouldn't be confused with onload event handling, despite Dean's title; it's to do with the DOMContentLoaded event, to use the Mozilla name for it, and how that can be emulated in IE and Safari. Footnotes: [1] <http://www.nickfitz.co.uk/2005/06/13/javascript-get-together- london-2005-06-11/> [2] <http://webstandards.org/action/dstf/> Cheers, Nick. -- Nick Fitzsimons http://www.nickfitz.co.uk/
- Follow-Ups:
- [Javascript] Onload event handlers for Safari
- From: Guillaume
- [Javascript] Onload event handlers for Safari
- References:
- [Javascript] Control the window
- From: Peter Lauri
- [Javascript] Onload event handlers for Safari
- From: Guillaume
- [Javascript] Control the window
- Prev by Date: [Javascript] Control the window
- Next by Date: [Javascript] Control the window
- Previous by thread: [Javascript] Onload event handlers for Safari
- Next by thread: [Javascript] Onload event handlers for Safari
- Index(es):