Jump-js code after 5 seconds

Source: Internet
Author: User

<!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.
-->

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.