Quick References
ADO
ASP
CSS2
HTML
JavaScript
Jet SQL
VBScript
WML
WMLScript
WSH
XHTML
XML DOM
XSLT
Features
Knowledge Base
Tutorials
Partners
ZVON.ORG
XML
Planet Source Code
VisualBuilder
Web Design
Your HTML Source
XML/XSLT Forums
ASPAlliance
Scripts
Programmers Heaven
Tek-Tips Forums
Developer Fusion
Code Project
All Objects
Window Object
window.setInterval
METHOD: Window::setTimeout
window.
setTimeout
(expression/function, milliseconds)
This method is used to call a function or evaluate an expression after a specified number of milliseconds. If an expression is to be evaluated, it must be quoted to prevent it being evaluated immediately. Note that the use of this method does not halt the execution of any remaining scripts until the timeout has passed, it just schedules the expression or function for the specified time.
The following example opens a new window and uses the
setTimeout
method to call the winClose() function which closes it after five seconds (5000 milliseconds).
Code:
function winClose() {
myWindow.close()
}
myWindow = window.open("", "tinyWindow", 'width=150, height=110')
myWindow.document.write("This window will close automatically after five seconds. Thanks for your patience")
self.setTimeout('winClose()', 5000)
In this example, the
setTimeout
method is used with the
onClick
core attribute in an
input
tag within the
body
element to call a function after five seconds (5000 milliseconds):
<html>
<head>
<script type="text/javascript">
function displayAlert()
{
alert("The GURU sez hi!")
}
</script>
</head>
<body>
<form>
Click on the button.
<br>
After 5 seconds, an alert will appear.
<br>
<input type="button" onclick="setTimeout('displayAlert()',5000)" value="Click Me">
</form>
</body>
</html>
Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information