网页定时转向代码
方法1:refresh转向
<html>
<meta http-equiv="refresh" content="0;url=http://www.panpan.org/">
</html>
方法2:js定时转向代码
<HTML>
<HEAD>
<TITLE>Timer</TITLE>
</HEAD>
<script language="JavaScript">
var time = 10;//设置倒数时间
function settimes()
{
if (time-- == 0) location.href="http://www.panpan.org";//要转向的页面
//时间递减
else document.all.aaa.innerHTML = time;
window.setTimeout("settimes()",1000)//1秒后再次调用函数
}
</script>
<BODY onLoad="settimes()">
<Center>
<H1 id="aaa">10</H1>
</Center>
</BODY>
</HTML>
注:此代码中<BODY onLoad="settimes()">,这一行是如果将BODY改为其他标签,均不能用,因为onload仅是BODY的属性参数,所以使用时请将onLoad="settimes()"加入BODY标签的属性里面,即如上所示。