Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
Thread: DOM works without window.onload
09-30-2003, 01:42 AM #1
- Join Date
- Jun 2002
- near Oswestry
- Thanked 0 Times in 0 Posts
DOM works without window.onload
This is slightly worrying - I was under the impression that properties of objects in mozilla are not available until the entire document has finished loading; but I just tried out a complex menu script I'm working on, processing the <ul> without window.onload, just ensuring that the initialisation calls happen at the end of the script, which is after the <ul> in the document.
<ul> ... blah ... </ul> <script> //object constructor //a few methods //call object constructor </script>"Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark
09-30-2003, 05:07 AM #2
Why would you need the page to fully load? The DOM is dynamic, especially so during page rendering. The entire <ul> node has been created in memory by the time your script is executed, so there shouldn't be any issues. Things to be concerned about would be accessing childnodes and siblings during page load, but that is the only thing I'd be concerned about.
09-30-2003, 08:17 AM #3
- Join Date
- Feb 2003
- Umeň, Sweden
- Thanked 83 Times in 74 Posts
Well, the thing is rather that the document is not finished yet, and thus the user agent doesn't necessarily provide getElementById, getElementsByTagName, body or documentElement properties of the document yet. Thus you can't rely on those being present, or if they are present, that they will work as they should. The node you want to handle itself, though, will be present and you can do anything you want with it.