大家来看看这个规定时间后跳转代码,该怎么处理
发布时间:2010-05-20 14:01:29 文章来源:www.iduyao.cn 采编人员:星星草
大家来看看这个规定时间后跳转代码
<script type= "text/javascript ">
<!--
var duration=2900;
var timer=null;
var endTime = new Date().getTime() + duration + 100;
function interval()
{
var n=(endTime-new Date().getTime())/1000;
if(n <=0)
{
document.getElementById( "timeout ").innerHTML = '0.000 ';
window.location.href= "http://blog.csdn.net ";
return;
}
document.getElementById( "timeout ").innerHTML = n.toFixed(3);
timer=setTimeout(interval, 10);
}
function stopJump()
{
clearTimeout(timer);
document.getElementById( "jumphint ").style.display = "none ";
}
window.onload=function()
{
//timer=setTimeout( "window.location.href= 'http://blog.csdn.net/ ' ", duration);
interval();
}
//-->
</script>
<span id= "jumphint "> 系统在 <span id= "timeout "> 3.000 </span> 秒后 将自动 </span> 跳转到 <a href= "http://blog.csdn.net "> BLOG首页 </a> <br />
<input type= "button " value= "停止自动跳转 " onclick= "stopJump(); this.disabled=true " />
是参照这里的改的主要是把
timer=setTimeout( "window.location.href= 'http://blog.csdn.net/ ' ", duration);
换到
if(n <=0)
{
document.getElementById( "timeout ").innerHTML = '0.000 ';
window.location.href= "http://blog.csdn.net ";
return;
}
把timer换成setTimeout(interval, 10);
暂时没发现什么错误
不知道哪个更好呢
------解决方案--------------------
这哪有什么哪种好的?
看需求嘛……
timer=setTimeout( "window.location.href= 'http://blog.csdn.net/ ' ", duration);
是在duration时间后直接把页面转过去
而
if(n <=0)
{
document.getElementById( "timeout ").innerHTML = '0.000 ';
window.location.href= "http://blog.csdn.net ";
return;
}
document.getElementById( "timeout ").innerHTML = n.toFixed(3);
这些代码是展现了计数过程,即计数未结束时不断倒计数,计数结束后转过页面。
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。
其他相似内容:
-
ASP如何隐藏表单
<%if Cookies_Toy ="" then
response.write "<a href='login.asp'>登录</a> <a href='reg.asp'>注册</a>"
...
-
为什么js调用css脚本后没效果
这个是css的脚本代码:
body,ul,li{margin: 0; padding: 0; border: 0;}
body {background: #f5f...
-
如何伪造post请求,求指点。。。
要查询大批(也就几万个)运单的状态,那查询网站一次最多查24个,这一个个搞会搞死人的。。
有...
-
Asp.net_简单代码设置GridView自适应列宽不变形
动态绑定的GridView由于列数不固定,而列又太多(博主做的这个项目有150个左右的字段...
-
ASP.NET下实现AJAX注册提醒
Ajax全称是,主要是利用JavaScript实现异步的数据传输,首先说异步,异步是当前操作进行的时候,用...
-
aspnet_regiis安装出错:0x80070005 拒绝访问
点击右边红色标题查看本文完整版:aspnet_regiis安装出错:0x80070005 拒绝访问安装...
-
关于网站边框
像hao123这样的网站上的边框是着么弄的?背景图片吗?http://www.hao123.com
另外哪个素材网站有实用的这内素材
-----...
-
求助!! 多表分组查询统计
高手们,帮帮忙!
用户表 D_user 为
ID Username GroupID
1 张三 2
2 李四 2
3 王五 ...
-
在Paypal提交的同时,把表单的数据提交给数据库
本帖最后由 liuyang2708 于 2012-11-20 23:14:54 编辑
在提交这个支付...
-
虚拟目录下JavaScript不能正常执行
各位大侠好,我在同一台服务器上用两种方式部署同一个网站。
第一种方法:在IIS下直接建一个网站...