Wednesday, August 31st, 2005

Breaking onload limits

Category: Editorial

<blockquote>

Every javascript coder, in almost every script, has encountered the onload limits. In this article we’ll present them briefly, together with some solutions.

The window.onload event handler has two main limits:

  • You can attach just one function to it
  • The script will wait until the page is fully loaded before running

Alessandro continues to discuss the onload limits and gets some interesting comments from the community:

  • Mozilla has a DOMContentLoaded event
  • Cameron Adams: Page flicker for CSS adjusting JavaScript can be greatly reduced by implementing a JavaScript-only stylesheet. This can be implemented before the tag has been closed (so well before the content has loaded), and can be simply done by switching on a linked stylesheet using JavaScript.
  • Mark Wubben: Unfortunately sometimes you do need to wait until `onload`. Safari for instance won’t lay out the page correctly until it’s been fully loaded, which means that for sIFR we had to do a special check for Safari so we could replace the elements earlier in other browsers. This problem is comparable to the non-incremental rendering of XHTML pages by Safari and Mozilla.

Related Content:

11 Comments »

Comments feed

i like to use a script that looks for “” in the document’s innerHtml.

i use that in my (non-ajax) image switcher (http://www.varal.org/media/imageswitcher/index.html) as you can see at the end of its code (http://www.varal.org/media/imageswitcher/imageswitcher.js)

Comment by tvst — September 6, 2005

correction:
i like to use a script that looks for “/body” in the document’s innerHtml.

man, for an ajax site it’s pretty tough to post a comment. maybe try using some ajax to give the user some real-time input? :)

Comment by tvst — September 6, 2005

Really helpful article. Especially thanks for the comment tvst. really helped me crack my problem. thanks again. http://callcenter.ramshyam.com

Comment by Live Order Taking — May 24, 2006

Really helpful. thanks guys. Especially the comments by tvst. Tried ajax and it worked. Really happy. Thanks again. :)
http://callcenter.ramshyam.com

Comment by Live Order Taking — May 24, 2006

Tried the same but didnt work. I have a call center company and OI wanted to integrate this solution into providing better quality service through the use of Java prohramming. Any ideas?

Comment by Call Center India — June 12, 2006

Tried to use the script fin my directory. Can’t crack it. Wonder where I am going wrong. I guess I just have to keep trying. I need to do something like what Christopher mentioned. For submitting your site to loads of directories, visit
http://www.submitboy.com

Comment by Submit a Site — July 27, 2006

Your live preview is really cool. How do you guys do it? Where can I get the script. Like to put it on my website. For free resume samples, tips and techniques
http://www.aroj.com

Comment by Resume Sample — July 27, 2006

Really helpful. thanks guys. Especially the comments by tvst. Tried ajax and it worked. Really happy. Thanks again. :)

Bettersense is an IT outsourcing company providing services for companies across the globe for the Medium & Large Scale Companies. We have clients from the US, UK, Australia, Denmark, Germany and India.

Comment by Jatin Sharma — May 29, 2007

Bettersense is an IT outsourcing company providing services for companies across the globe for the Medium & Large Scale Companies. We have clients from the US, UK, Australia, Denmark, Germany and India.

http://www.itoutsourceonline.com/

Comment by Jatin Sharma — May 29, 2007

Outsource Back Office, is the fastest growing Back Office Support and Helpdesk Solution company in India. We specialize in supporting your company at back end in efficient way. Many companies are outsourcing their support work to us, Try us once and see the difference.

Do you want someone to complete your work on an as needed basis?
If you are considering offshoring your processes, or would just like to know more about the various BPO / KPO services that can be outsourced to us in India, kindly contact us and our customer service representatives will get back to you soon.
For outsourcing chat, email or back-office support, visit the website: http://www.outsourcebackoffice.com

Comment by Sharad Saxena — May 30, 2007

I thought it was a great article. I am against the NSA domestic spying program for many reasons. One of which – the program reminds me too much of the former USSR. The goverment watching over it’s people “for their own good”. No matter how noble the intention of the government – the old saying “absolute power corrupts absolutely” comes to mind. This program will be used somehow in a way it was not advertised to the US people. The US government has used the threat of terrorists and terrorism to undermine a host of civil liberties in the last few years. And the majority of the US population doesn’t mind or care (in my opinion). lets forrgot all these things and just concentrate on our search

Comment by logical — October 19, 2007

Leave a comment

You must be logged in to post a comment.