brothercake
04-19-2004, 01:38 PM
window.onload doesn't fire until all external dependencies are resolved, right? But image loading is asynchronous, and a DOM structure doesn't need all the images to have loaded before it can be accessed.
So is there a way to detect the state where the DOM is ready, without reference to asynchronous dependencies?
liorean
04-19-2004, 02:04 PM
I don't know whether such a mechanism exists, but you could always try checking whether readystate or onreadystatechange can bew used for it. I belive they're implemented in newer moz versions, op7, iem and iew. I don't know about saf, though.
If they don't work, try ondocumentready or oncontentready in ie.
DHTML Kitchen
04-19-2004, 03:34 PM
window.onload doesn't fire until all external dependencies are resolved, right? But image loading is asynchronous, and a DOM structure doesn't need all the images to have loaded before it can be accessed.
So is there a way to detect the state where the DOM is ready, without reference to asynchronous dependencies?
Onload fires only after all the media, images, et c have loaded, right?
Do you have a test case where onload fires and images are not yet loaded? I've never seen that happen.
liorean
04-19-2004, 04:34 PM
It doesn't - but what he was asking for was a method of doing just that.
brothercake
04-20-2004, 07:01 PM
Exactly :)
I shall try some of those ideas and post the results.
DHTML Kitchen
04-21-2004, 03:03 PM
Why not the old script before closing body tag?
<script type='text/javascript'>
window_loaded();
</script>
</body>
</html>
brothercake
04-21-2004, 06:01 PM
Well I don't want to to impose restrictions on where in the source code the scripting has to be.
But would that reliably work anyway? Isn't that just the same as calling the initialising function from there, and hence vulnerable to the page DOM possibly not being ready at all, as it gets to that script before the document has finished rendering ..?
DHTML Kitchen
04-22-2004, 02:12 PM
At that point, the browser has the whole document (except the closing tags for body and html, but that's OK) You basically have the whole document, but media (images, movies, et c) will still be downloading You can call document.getElementsByTagName w/o unexpected results, or do any other DOM stuff.
If you find another way to do it, post it up - I'd like to know.
brothercake
04-22-2004, 04:22 PM
I still wouldn't be happy with that ... it would make me nervous. I had that thought a while ago and I was talked out of it http://www.codingforums.com/showthread.php?t=26998
Anyway I still haven't tried any of this ... so many things ... :)