As follows:
Copy codeThe Code is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Title> </title>
<Style type = "text/css">
# Main {border: 1px solid black; width: 200px; margin: 0px auto; padding: 100px ;}
</Style>
<Script type = "text/javascript">
Window. onload = function (){
// The first method to call is to pass the method pointer.
// SetInterval (showMsg, 1000 );
// Method 2
Var methodName = "showMsg ()"; // note that strings are used and parentheses are added.
SetInterval (methodName, 1000); // double quotation marks are added to indicate that the Code is in it, and the code in the execution will be similar to setInterval ("alert ('A')", 1000 ), execute alert ('A') every 1 second ')
}
Var seconds = 5;
Function showMsg (){
If (seconds> 0 ){
Seconds --;
Document. getElementById ("msg"). innerHTML = seconds + "is automatically disabled in seconds! ";
}
Else {
Window. close ();
}
}
</Script>
</Head>
<Body>
<Div id = "main">
This is an advertisement form:
<Div id = "msg"> it is automatically disabled in 5 seconds! </Div>
</Div>
</Body>
</Html>