编程中国 | 业界新闻 | 技术文章 | 视频教程 | 下载频道 | 程序源码 | 个人空间 | 编程论坛  
全能 ASP / PHP / ASP.NET 主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付学习型 ASP/PHP/ASP.NET 主机 30元/年
发新话题
打印

[求助]如何要页面在停留3秒后自动条转到首页!

[求助]如何要页面在停留3秒后自动条转到首页!

如何要页面在停留3秒后自动条转到首页!关键是怎么设置时间的(3秒!)

TOP

就象我们在这论坛帖时!发完后。提示3秒后自动跳转到发页面。!!
回头→守望过去岁月 →在我们身上刻下了无法抹去的痕迹→在午夜里→ 静静听见→有人说→过去了→过去了

TOP

<META HTTP-EQUIV="REFRESH" CONTENT="3; URL=http://www.bc-cn.net" />

TOP

给个JS写的"倒数"类
countdown.js

function countdown() {
this.second = 0;
this.url = "";
this.idinterval = false;
this.isStop = false;
window.obj = this;
this.cd = function() {
this.second--;
if (this.second <= 0) {
window.location = this.url;
clearInterval(this.idinterval);
}
this.writesecond();
}
this.cd_start = function() {
if (document.getElementById("span_countdown") == null)
document.write("<span id=\"span_countdown\" style=\"color:#0066CC\">" + this.second + "</span>");
this.idinterval = setInterval("obj.cd()",1000);
}
this.cd_stop = function() {
clearInterval(this.idinterval);
}
this.writesecond = function() {
document.getElementById("span_countdown").innerHTML = this.second;
}
this.stop_and_goon = function() {
if (this.isStop) {
this.isStop = false;
this.cd_start();
}
else {
this.isStop = true;
this.cd_stop();
}
}
}

使用例子:
<script language="javascript" src="countdown.js"></script>

<script language="javascript">
var cd = new countdown();
cd.second = 9;
cd.url = "<?=$_GET['url']?>";
cd.cd_start();
</script>
秒后自动跳转
<p>
<a href="###" onclick="cd.stop_and_goon()">暂停|开始</a>

TOP

js问题也跑这里问。。。

TOP

是把问题复杂化了。

可以弄个简单一点的嘛。

<META HTTP-EQUIV="REFRESH" CONTENT="3; URL=<?php echo $url?>" />

但是、4楼版主的JS,能让用户自定暂停/开始,也是一个很实用的功能。
                  
广告位出租,有意短信详谈...
另卖艺卖身,有意短信联系...

TOP

发新话题