View Full Version : Determinining if a page has loaded completely

Jun 18th, 2002, 10:30 PM
Hello all,

Is there a way to determine if a page has loaded completely?

Also is there a way to determine if items on a page have also completely loaded?


Jun 18th, 2002, 10:36 PM

what do you need?

if you use a Javascript, launch it when the page is finished loading...

<script language="JavaScript">
function sendMessage()
alert('The page has loaded completely!');
<body onLoad="sendMessage();">

That'll do it.


Jun 18th, 2002, 10:38 PM
I assumed that the onload is the 1st event that occurs; I want to make sure that the page has rendered completely...can this be captured?

Jun 18th, 2002, 10:40 PM
If the onLoad event has fired, the page has completed loading...

what more do you need?

Please explain in details what you're trying to accomplish


Jun 18th, 2002, 10:40 PM
I want to know if specific elements are loaded....

Jun 18th, 2002, 10:42 PM
I do not think this is possible - specific elements .. such as a picture?

Jun 18th, 2002, 10:43 PM
Does the complete method work for all objects?
eg: object.complete

Jun 18th, 2002, 10:45 PM
Never heard of that...

sorry Krazy, you gotta give me credit though, I did answer your first question... :D


Jun 18th, 2002, 10:50 PM
Yup you are correct!

You did answer the 1st one!! Thanks...sorry for not explaining my questions as refined as possible...if there is such a method to determine if specific elements have loaded I would like to know...

Thanks again QuackHead!

Jun 18th, 2002, 11:01 PM
I think what you are referring to is the readyState property. In IE4+ you should be able to refernece the readySate property like so:

var x= document.readyState

which should return 1 of 5 different values:


so to see if a element is in fact completely loaded you could use:

var pic=document.images.picname.complete

which will return true or false depending on the current readySate of that image.

Jun 18th, 2002, 11:04 PM
Thanks for the info JohnKrutsch!
Is there an NS equivalent for the readyState?

Jun 18th, 2002, 11:15 PM
Not according to Alex Vincent's JavaScript Developers Dictionary. Sorry

Jun 18th, 2002, 11:21 PM
Ok thanks!

Well, I was thinking if you were to need this event for dynamically creating objects; I suppose that if this method is only for images...

Jun 19th, 2002, 07:42 PM
Tis should work although I download the picture so fast I can't see if it works.

<title> </title>
<div id="stats"> </div>
<img name="pic" src="http://home.centurytel.net/jcjoel2002/shed.jpg" width="640" height="480" />
<script type="text/javascript">
function redy(){
var x= document.images.pic.readyState;
if(x=="complete") clearInterval(abc);

Jun 19th, 2002, 09:37 PM
My cent in.
As far as images are concerned, they are respondent to onLoad <img src.... onLoad="">
if you know how many images in a page are or how many are chached for rollovers (I bet this might be one of the underlying problems), you can instruct each image to run a function upon being loaded:
var finish=0;
function addF(){++finish}

then each image <img ... onLoad="addF()">

and for prechached you may try:

var anImm=new Image(100,100)

To know if a page has loaded all its graphical elements then, you recursively check with a timeout until
finish= your amount of images

maybe it is an adjunctive hint for your problem

Jun 26th, 2002, 11:16 PM
I was reading this and added the following to my page to see the readystate and it returns loading.

Would this explain why the onload would not work..........

When does it become a loaded state.