當(dāng)網(wǎng)頁運(yùn)行一定的時(shí)間后,自動關(guān)閉網(wǎng)頁上指定的廣告窗口。
本實(shí)例主要應(yīng)用window對象的setTimeout()方法和close()方法來實(shí)習(xí).window對象的setTimeout()方法用于延遲執(zhí)行某一操作。
1.要關(guān)閉的廣告窗口。
<html>
<head>
<title>打開新窗口顯示廣告信息</title>
<style type="text/css">
body{
background-image:url(new.jpg);
background-repeat:no-repeat;
}
</style>
</head>
<body></body>
</html>
2.實(shí)現(xiàn)關(guān)閉功能的頁面
<html>
<head>
<title>自動關(guān)閉廣告窗口</title>
<script type="text/jscript" language="javascript">
function pp()
{
window.open("new.html","new","height=280,width=800,top=10,left=20,resizable=no, location=no",false);
}
</script>
</head>
<body onload = "window.setTimeout('window.close()',5000)">
</body>
</html>