Forum Moderators: open
window.onload = setTimeOut(1000); But it seemed to have no effect. Here's something else I tried, which also had no effect:
window.onload = function(myFunction) {
setTimeOut(10000);
} I also tried this, in my actual HTML document:
<body onload="setTimeOut(1000)"> Also with no effect.
So what am I missing here? I've read through a couple tutorials but couldn't find any solution. Would appreciate any input.
Thanks,
Matthew
So something like this should work:
<body onload="setTimeout('myFunction(12)',1000);">
When the onload event fires, it will set a timer for 1 second. After one second, the timer will execute the javascript in the first parameter. In this example it will call myFunction and pass a parameter of 12.
Remember - the onLoad event is supposed to be fired after the page is finished loading. So it may be sufficient to put your code in the onLoad of the body tag. If there are critical external files (such as other javascript, images, etc.) then it is possible that they won't be done loading when the onLoad fires. In this case setTimeout will definitely help you.