This is an Internet Explorer only method. It does not produce the expected results on other browsers.
It is meant to be used as an IE alternative in other fine scriptstrying to fix the window onload problem.
It is based on a hack (no doubt about that), but I hope it is an improvement over previous IE hacks.
Several tests has showed that the only other (documented)method covering all the aspects of this complex problem is the original Microsoft HTC method as described by Dean Edwards in An Alternative Solution.
However an inline solution is always preferred, possibly XHTML compatible, with no document.write and without requiring external files.
The solution I show here uses the "doScroll()" method in a try/catch polling loop. This triggers when no errors are returned by "doScroll().
You can quickly download the small iecontentloaded.jsscript or just have a lookat it.
The Microsoft online documentation About Element Behaviors tell us something about this:
When the ondocumentready event fires, the document has been completely parsed and built. Initialization code should be placed here if the component needs to navigate the primary document structure. The ondocumentready event notifies the component that the entire page is loaded, and it fires immediately before theonload event fires in the primary document.
A few methods, such as doScroll, require the primary document to be completely loaded. If these methods are part of an initialization function, they should be handled when the ondocumentreadyevent fires.
The objective of these tests is to compare the detection reliability of this method.
In this specific case we are interested in determining when all the nodes in the
requested page have been loaded and parsed in the DOM and available to scripts.
The fact that images exists or not in the page shouldn't affect this test.
The test case executes these steps, in sequence, at different times:
The page should have a "green" background color after being loaded completely.
If that is not the case then something went wrong in my script or in your browser.