实现几秒后跳转到另一页面JS

时间:2022-11-28 17:19:09

:<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Loading</title>
</head>

<body>

<form name="loading">

<p align="center">正在跳转,请稍后...</p>

<p align="center">
<input type="text" name="bar" style="border-style:none; background-color:#D3E8D0; font-weight:bold" />
<input type="text" name="percentage"style="border-style:none; background-color:#FFFFFF; max-width:30px"/>
</p>

<p align="center">
如果您的浏览器不支持跳转,请点击<a href="http://www.126.com">这里</a>手动跳转
</p>

<script language="javascript" type="text/javascript">
var percent=0; //百分比进度,显示在滚动条后面
var element="||"; //滚动条单元竖线
var elements="||"; //滚动条当前竖线
count(); //开始调用循环

function count(){
percent=percent+10; //每次百分比加10
elements =elements + element; //滚动条当前竖线增加一个滚动条单元竖线
document.loading.bar.value=elements; //设置窗体loading表单中bar元素的当前值
document.loading.percentage.value=percent+"%"; //设置窗体loading表单中percentage元素的当前值
if (percent<99){ //percent小于99则继续循环
setTimeout("count()",500); //每500ms进行一次count()
}
else{
window.location = "http://www.baidu.com"; //percent达到100时跳转
}
}
</script>

</form>
</body>
</html>