21,893
社区成员




<meta http-equiv="refresh" content="2;URL=http://www.test.net">
<html>
<head>
</head>
<body>
<input type="button" name="btn" id="btn" value="" style="width:100px" disabled >
</body>
<script type="text/javascript">
var i = 10;
var s = 1000;
(function countDown()
{
var btn = document.getElementById('btn');
if(i != 1)
{
btn.value="click("+i+")";
i--;
}
else
{
btn.value="click";
btn.disabled = false;
return;
}
setTimeout(function(){countDown()},s);//
})();
</script>
</html>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script type="text/javascript">
/**
* 计数器(倒数)
* @author MoXie SysTem128@GMail.Com
*
* IE6,7 Firefox2.0 Opera 9.25 测试通过
**/
var timer = {
// 元素id
elId : null,
// outTime : null,
// 初始文本
text : null,
// 技术文本格式
countFormat : null,
// 当前数
current : 0,
// 获取操作对象
getEl : function(){
return document.getElementById(this.elId);
},
// 计数
counter : function(){
this.current--;
if (this.current>0){
this.writer(1);
}else if (this.current == 0){
this.writer(0);
this.onEnd();
}
return true;
},
// 显示
writer : function(isCount){
var el = this.getEl();
if (!isCount)
{
el.value = this.text;
}else{
var counterText = this.countFormat.replace("$count",this.current);
el.value = this.text+counterText;
}
},
// 起始时触发的动作
onStart : function(){},
// 中止时触发的动作
onEnd : function(){},
// 初始化
/**
* elId 元素id
* text 初始文本
* outTime 个数
* speed 速度 1000 = 1秒
* countFormat 计数显示格式 嵌入数字使用 $count
* onStart 起始 动作
* onEnd 结束 动作
**/
init : function(elId,text,outTime,speed,countFormat,onStart,onEnd)
{
this.elId = elId;
this.text = text;
this.current = outTime+1;
this.countFormat = countFormat;
if (typeof(onStart) == "function")
{
this.onStart = onStart;
onStart();
}
if (typeof(onEnd) == "function")
{
this.onEnd = onEnd;
}
window.setInterval("timer.counter()",speed);
}
}
// 这里留为自定义
var myStart = function(){
var el =document.getElementById("submitBtn").setAttribute("disabled",true);
alert("Hello!");
}
var myEnd = function(){
document.getElementById("submitBtn").removeAttribute("disabled")
alert("Goodbye!");
}
</script>
<input type="submit" id="submitBtn" value="确认" />
<script type="text/javascript">
/**
* elId 元素id
* text 初始文本
* outTime 个数
* speed 速度 1000 = 1秒
* countFormat 计数显示格式 嵌入数字使用 $count
* onStart 起始 动作
* onEnd 结束 动作
**/
timer.init("submitBtn","确认",2,500,"($count)",myStart,myEnd);
</script>