<!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd "><HTMLxmlns= "http://www.w3.org/1999/xhtml"><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" /><title>Jump to Baidu after 5 seconds</title><Scripttype= "Text/javascript">functionTime () {var Time=document.getElementById ("Second"). InnerHTML; if( time>0) {document.getElementById ("Second"). InnerHTML= Time-1 }Else{location.href="http://www.baidu.com"; } }</Script></Head><Bodyonload= "SetInterval (' Time () ',") "> <P><spanID= "Second"style= "color: #CF3;">5</span>Seconds after the jump to Baidu</P></Body></HTML>
<!--
settimeout ()
Syntax
var t=settimeout ("javascript statement", milliseconds) the first parameter of
SetTimeout () is a string containing JavaScript statements. This statement may be such as "alert (' 5 seconds! ')" or a call to a function, such as alertmsg () ". The
second parameter indicates how many milliseconds from the current date to execute the first parameter.
Hint: 1000 milliseconds equals one second.
setinterval () method to invoke a function or evaluate an expression by a specified period, in milliseconds. The
SetInterval () method keeps calling functions until Clearinterval () is called or the window is closed. The ID value returned by SetInterval () can be used as a parameter to the Clearinterval () method.
settimeout () vs setinterval ()
SetTimeout () executes code only once. If you want to call more than once, use SetInterval () or let code itself call SetTimeout () again.
-->