[JS]Delay not working

Experienced Elementalist
Joined
Apr 15, 2008
Messages
256
Reaction score
0
<div id="notice">
Getting Stats please wait!..</div>
<body onload="javascript:setTimeout(stats(),5000);"></body>
</div>
<script type="text/javascript">
function stats(){
document.getElementById('notice').innerHTML = '<notice>' +'One paragraph of text to replace the previous two ' +'paragraphs.<\/notice>';
}
</script>
It would just instantly load the stats, instead of waiting 5 seconds.
and also this one:
function switchpage(location){
document.getElementById('content').innerHTML = '<notice>Loading New Page, Please Wait...<\/notice>';
setTimeout(window.location=location,5000);
}
I just see Loading new Page, please wait... then it immediately changes :(
any reasons why?
 
I think the first argument has to be a function, of setTimeout()

setTimeout(function() { window.location=location; },5000);
 
Back