Monday, February 5th, 2007
Peter Michaux has written a detailed post on the window.onload problem:
Peter goes into detail on the various tricks and hacks that differ between browsers in many cases.
- Just putting a script tag where you need it
- DOMContentLoaded for some browsers
- script tag with an onreadystatechange
- DOM Polling (e.g. YUI event library)
Event handler attributes in the HTML are the most robust but do not allow separation of concerns.
Dean Edwards script allows for complete separation but is brittle when looking towards the future. Old and exotic browsers will not enliven a page until window.onload.
DOM polling is cross browser, robust and allows for complete separation of concerns. In extremely rare cases a dummy element can help the code know that content is available.
Posted by Dion Almaer at 8:04 am