Solved

window or body onload

Posted on 2004-04-12
5
6,654 Views
Last Modified: 2012-06-27
I have a script that generates the size of div's on a page, but there's a noticeable delay in IE.
Is there any functional difference (in how fast the browser process the script) by using window.onload or body onload

Thanks,
Sean
0
Comment
Question by:seanpowell
  • 3
  • 2
5 Comments
 
LVL 16

Expert Comment

by:jaysolomon
ID: 10808407
i mainly use

<head>
<script>
window.onload = function(){
     // do something
        // ...and something a lil more complex
}
</script>
</head>

and never have any timing problems.

another option may be to have everything (HTML) in a div container and leave it hidden for X seconds and when your script gets
thru processing have a statement in it that says if (done) show the container

hope this helps
0
 
LVL 31

Author Comment

by:seanpowell
ID: 10808432
Well the script just compares the height of one div based on its internal content, and then makes the div next to it the same height.

In IE though, the window loads, and "then" the div stretches to match the other one. I was just curious if window or body onload were two different things or not...
0
 
LVL 16

Accepted Solution

by:
jaysolomon earned 500 total points
ID: 10808458
i like window.onload = ....... i feel (and this is my opinion) that when the pages gets hit it will see window...... before the DOM gets to body onload=.............

this is my opinion
0
 
LVL 31

Author Comment

by:seanpowell
ID: 10817751
You're opinion's always been good enough for me jAy :-)
Pts increased...
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 10823030
glad to have helped and thanks for the A and Points
jAy
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now