Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 587885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:15:35+00:00 2026-05-13T15:15:35+00:00

I am having trouble with some JavaScript running before the page is completely rendered

  • 0

I am having trouble with some JavaScript running before the page is completely rendered in IE 6 (maybe other versions too but just testing IE6 for now. Firefox seems to be OK). I can get around this by calling the js on window.onload like this:

window.onload = function(){doIt();}

However, my concern is the fact that I will overwrite anything else that may already be in window.onload. The code will be used as part of a library so I can not guarantee that window.onload will not be set somewhere else by someone else. I would rather append my function to the onload event like this:

window.onload += function(){doIt1();}
window.onload += function(){doIt2();}

But when I do so, only doit2() is called. Is there a way to register an event handler for when the page is fully rendered? My second thought would be to just put my code in a loop checking to make sure all my objects exist before running. But I am scared that this could potentially lockup the browser.

Just for some background info, my code is hiding/showing iFrames. I know that I can use the iFrame’s onload attribute but I need all of the iFrames to be fully loaded before calling the code.

Any thoughts from the community? Thanks in advance for you input.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T15:15:35+00:00Added an answer on May 13, 2026 at 3:15 pm

    Use this generic addLoadEvent function…

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

    This essentially queues up functions to be executed. It never overwrites a previously assigned handler. Sample usage below…

    addLoadEvent(function() { alert("One!"); });
    
    addLoadEvent(two);
    function two() {
      alert("Two!");
    }
    

    I want to mention that libraries like jQuery take care of known issues like this for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My Javascript is quite basic, but for some reason I am having trouble. I
I'm having trouble with some JavaScript that I've written, but only with Internet Explorer
I am having some trouble with the classic javascript local variable scope topic, but
I am having some trouble calling a javascript function inside of the html page.
I am having trouble with some javascript. The code snippet below creates a simple
I'm having trouble getting some javascript and Jquery to delay the appropriate amount of
I'm pretty new to JavaScript and I'm having trouble with some of the properties
I have an idea for a web application and I'm having some javascript trouble.
I am having some trouble parsing xform xml with javascript. The structure of the
I'm having some trouble passing an array from controller to a javascript in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.