faqts : Computers : Programming : Languages : JavaScript : Event handling

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

13 of 16 people (81%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

When a page is loaded (onLoad) does this mean the data can be seen on screen?

Nov 12th, 2003 06:41
Russ Locke, Thursday Next,


onload fires when the page has completely loaded and rendered the html.
this is atleast true for MSIE (and I'm pretty sure true for NS).
I use this event scenerio for displaying a download progress meter 
which clears onload.
I do this by:
<html>
<head>
<script language="javascript">
    window.status = "loading page";
    document.write("<a name='progressindicator'></a>");
    document.write("<span id='loadingpage' 
style='visibility:hidden'><table height=100% width=100% border=0><tr 
height=100%><td width=100% align=center valign=center><img 
src='process_meter.gif' border=0 id='progressimage'><br><br>");
    document.write("loading page");
    document.write("</td></tr></table></span>");
    var progressTimeID = setTimeout
("window.location.hash='progressindicator';document.getElementById
('loadingpage').style.visibility='visible';", 1500); // only display if 
it seems we are taking too long
function clearProgress() {
  clearTimeout(progressTimeID);
  window.status = '';
  document.getElementById('loadingpage').innerHTML="";
}
</script>
</head>
<body onload="clearProgress();">
blah
</body>
</html>