Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    May 2003
    Location
    Chicago, IL
    Posts
    131
    Thanks
    3
    Thanked 0 Times in 0 Posts

    onLoad function executing slow in FF

    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?
    Code:
    function addLoadEvent(func) {
        var oldonload = window.onload;
        if (typeof window.onload != 'function') {
            window.onload = func;
        } else {
            window.onload = function() {
                if (oldonload) {
                    oldonload();
                }
                func();
            }
        }
    }
    
    function getHeight() {
       elem1 = document.getElementById("container-top");
       elem2 = document.getElementById("content-container2_subpages");
       offSet = Element.getHeight( 'footer' ); //Prototype call
       contentHeight = document.body.offsetHeight;	
       if(elem2){
           elem1.style.height = (contentHeight - 260)  + 'px';
       }else{
           elem1.style.height = (contentHeight - 360)  + 'px';
       }
       
    }
    
    addLoadEvent(function() {
    getHeight();
    })
    Would anyone have an idea as to why there is a delay in FF, and how to rectify?

    Thanks in advance.

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    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.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    Regular Coder
    Join Date
    May 2003
    Location
    Chicago, IL
    Posts
    131
    Thanks
    3
    Thanked 0 Times in 0 Posts
    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.
    Last edited by hothousegraphix; 07-07-2007 at 08:11 AM.

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Hmm neither page seems to be functioning properly in Firefox 2.0.0.4

    Looks like some of your javascript is missing.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #5
    Regular Coder
    Join Date
    May 2003
    Location
    Chicago, IL
    Posts
    131
    Thanks
    3
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •