javascript定时关闭一个层,主要使用的在网站广告方面,代码如下:
[code]
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<SCRIPT LANGUAGE="javascript">
setTimeout('f()',5000);
function f()
{
document.getElementById("AdLayer").style.display="none";
}
</SCRIPT>
</head>
<body>
aaaaaaaaaaaaaa<br />
aaaaaaaaaaaaaa<br />
bbbbbbbbbbbbbb<br />
aaaaaaaaaaaaaa<br />
aaaaaaaaaaaaaa<br />
bbbbbbbbbbbbbb<br />
aaaaaaaaaaaaaa<br />
aaaaaaaaaaaaaa<br />
bbbbbbbbbbbbbb<br />
aaaaaaaaaaaaaa<br />
aaaaaaaaaaaaaa<br />
bbbbbbbbbbbbbb<br />
<div id=AdLayer style="position:absolute; width:160px; height:59px; z-index:20; left: 50px; top: 100px; background-color:#CCCCCC; border:1px solid #FF0000;">
</div>
</body>
</html>
[/code]