PDA

View Full Version : [JS] Loading after a certain time..



MrCraig
10-04-2008, 01:45 PM
Havent seen one posted, but whats the function to carry out an action after a certain time.

Whats happening in my case is im using a function that loads the entire website, that same function loads the pages inside the website, but it seems to be loading the things inside the page before the actual page has finished loading.. :|

Any help anyone.?

Code.



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>HabboRave</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style typ="text/css">
body{font-family:verdana; font-size:11px; color:#000000; background-image:url(bg/hab_grey.png); background-attachment:fixed;}
#adverts{background-image:url(img/adverts_rollover.gif); background-position:top;}
#adverts:hover {background-image:url(img/adverts_rollover.gif); background-position:bottom; cursor:pointer;}
#adverts_selected{background-image:url(img/adverts_white.gif);}

#dj{background-image:url(img/dj_rollover.gif); background-position:top;}
#dj:hover{background-image:url(img/dj_rollover.gif); background-position:bottom; cursor:pointer;}
#dj_selected{background-image:url(img/dj_white.gif);}

.hr_stats{background-image:url(img/habborave_r3_c15.gif); padding:0px; font-family:verdana; font-size:11px; font-color:#FFFFFF;}
</style>

<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js"></script>
<script type="text/javascript">
function cpage(page)
{
document.getElementById("hr_content").innerHTML = '<img src="img/load_big.gif" border="0" /><br />Loading...';
new Ajax.Updater('hr_content',page);
}
function stats()
{
document.getElementById("hr_stats").innerHTML = '<img src="img/load_small.gif" border="0" />';
new Ajax.Updater('hr_stats','page/stats.php');
}
function initpage()
{
document.getElementById("main_div").innerHTML = '<img src="img/load_big.gif" border="0" /><br />Please wait whilst HabboRave Loads...';
new Ajax.Updater('main_div','habborave.htm');
stats();
setInterval("stats()",40000);
}
</script>
</head>
<body onload="initpage();">
<div id="main_div" align="center">
</div>
</body>
</html>

Agnostic Bear
10-04-2008, 01:46 PM
setTimeout("functionname", time in ms);

MrCraig
10-04-2008, 01:48 PM
Oooh. Ty Dan :)

Any suggestions how else i could do this, as obv the loading time for everyone varies...

Agnostic Bear
10-04-2008, 01:53 PM
Oooh. Ty Dan :)

Any suggestions how else i could do this, as obv the loading time for everyone varies...

Yep, this'll do it as soon as their page has loaded:

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

MrCraig
10-04-2008, 02:00 PM
Not working..

Getting the document.getElementById("hr_stats") has no properties error message again..

Agnostic Bear
10-04-2008, 02:12 PM
Not working..

Getting the document.getElementById("hr_stats") has no properties error message again..

There's no element with the id hr_stats (e.g <div id="hr_stats">)

MrCraig
10-04-2008, 08:24 PM
There is..

It works on the setInterval method..
So it must work..

Or when i call the function manually from the browser location.

Agnostic Bear
11-04-2008, 05:02 AM
There is..

It works on the setInterval method..
So it must work..

Or when i call the function manually from the browser location.

The error is saying there isn't.

Want to hide these adverts? Register an account for free!