As shown below:
Copy the code code 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 calling method passes the method pointer
//setInterval(showMsg, 1000);
//Second calling method
var methodName = "showMsg()"; //Note that a string is used here and parentheses are added
setInterval(methodName, 1000); //Double quotes are added to indicate that there is code inside. The code inside will be executed similar to setInterval("alert('a')",1000), and alert('a' will be executed every 1 second )
}
var seconds = 5;
function showMsg() {
if (seconds > 0) {
seconds--;
document.getElementById("msg").innerHTML = seconds + "Automatically close after seconds!";
}
else {
window.close();
}
}
</script>
</head>
<body>
<div id="main">
This is the advertising form:
<div id="msg">Automatically close after 5 seconds! </div>
</div>
</body>
</html>