View Full Version : onLoad function executing slow in FF

07-07-2007, 04:38 AM
I'm running the following function as an onload event to adjust the height of several elements within my page layout. It does function, however, in FF there is quite a noticeable delay which causes a flashing that is not what would be considered acceptable..

I was about the scrap this altogether, rearrange my layout to handle purely with CSS...but I checked in IE7 first. It works just fine with no visible delay.

Which makes me wonder if there is a better, more reliable way to achieve what I'm trying to do?

function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {

function getHeight() {
elem1 = document.getElementById("container-top");
elem2 = document.getElementById("content-container2_subpages");
offSet = Element.getHeight( 'footer' ); //Prototype call
contentHeight = document.body.offsetHeight;
elem1.style.height = (contentHeight - 260) + 'px';
elem1.style.height = (contentHeight - 360) + 'px';


addLoadEvent(function() {
Would anyone have an idea as to why there is a delay in FF, and how to rectify?

Thanks in advance.

07-07-2007, 05:11 AM
Do you have any other onload events? The way the addLoadEvent function works is it runs everything else on load and only after those functions are ran will the getHeight() function run. Can you post a link to your page? There is likely a better way to do what you want and possibly without using javascript.

07-07-2007, 06:17 AM
Hello, thanks for responding.

I do, in fact, have two other functions being called in the same addLoadEvent function.

This example is showing the else portion of the function:
url removed

This example is showing if(elem2) portion of the function:
url removed

(if you're viewing in IE6, I apologize...the project has yet to be optimized for IE6)

I'm using this function to correct situations when not enought content exists to push the bottom of the layout below the fold. When the conditions exist to create this situation
the footer does not stretch to the base of the browser window...so...to compensate, I've made the site body BG the same color as the footer BG; creating the illusion that the
footer stretches.

This is all fine an good until content stretches the site, beyond the point that my inner containers BG color can cover...so...then I get a big blast of the site body BG where it
shouldn't be.

One thought I had was to adjust my function to handle the footer, rather then dealing with the inner containers. So really, the function would only act in situations where the
footer didn't meet the bottom of the browser window.

I hope this all makes sense.

07-07-2007, 07:59 AM
Hmm neither page seems to be functioning properly in Firefox

Looks like some of your javascript is missing.

07-07-2007, 08:10 AM
Sorry...I was actually working on a solution. Which I've come up with.

It involves the addition of a wrapper div which sits just above the body. I am then going to take my own advice and address only the one situation (when content is not sufficient to push the bottom of the layout below the fold).

It seems to make more sense to address the one instance directly rather then
try to and adjust everything to accommodate a situation that may not even occur.

When it does, I'll run a function to adjust the height of the new "wrapper" div (shortening it) in order to expose the BG color of the site body to establish the footer height illusion discussed above.