将某个按钮禁用5秒钟
我想在页面加载时,前5秒将btnTJ按钮禁用,请问我怎么写代码 --------------------编程问答-------------------- 以前以为高手给出的答案是利用时间差 两个时间相减 --------------------编程问答-------------------- 取出系统的当前时间的秒
然后和加5进行比较 --------------------编程问答-------------------- 给代码看看阿 --------------------编程问答-------------------- 使用js
<script type="text/javascript">
<!--
var secs = 9;
var wait = secs * 1000;
var btnId = "BtnRegStep1";
document.getElementById(btnId).value = "我同意 [" + secs + "]";
document.getElementById(btnId).disabled = true;
for(i = 1; i <= secs; i++)
{
window.setTimeout("Update(" + i + ")", i * 1000);
}
window.setTimeout("Timer()", wait);
function Update(num)
{
if(num != secs)
{
printnr = (wait / 1000) - num;
document.getElementById(btnId).value = "我同意 [" + printnr + "]";
}
}
function Timer()
{
document.getElementById(btnId).disabled = false;
document.getElementById(btnId).value = " 我同意 ";
}
//-->
</script> --------------------编程问答-------------------- setTimeout() --------------------编程问答-------------------- weizhuangzhi(壮志 ☆☆☆☆☆)。。。
var btnId = "BtnRegStep1";??不懂 --------------------编程问答-------------------- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script>
var count=1;
function showButton(){
alert(count);
if(count==5){
document.getElementById("btnTest").disabled="";
clearInterval(tmrId);
}else{
count++;
}
}
var tmrId=setInterval(showButton,1000);
</script>
</head>
<body onload="">
<input type="button" id="btnTest" disabled="disabled" value="Test" />
</body>
</html> --------------------编程问答-------------------- <body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="宋体">
<asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 336px; POSITION: absolute; TOP: 168px"
runat="server" Width="256px" Height="112px" TextMode="MultiLine"></asp:TextBox>
<asp:TextBox id="TextBox2" style="Z-INDEX: 102; LEFT: 328px; POSITION: absolute; TOP: 304px"
runat="server" Width="264px" Height="128px" TextMode="MultiLine"></asp:TextBox>
<asp:Button id="Button1" style="Z-INDEX: 103; LEFT: 216px; POSITION: absolute; TOP: 104px" runat="server"
Text="Button" Enabled="False"></asp:Button></FONT>
</form>
<script language="javascript">
var count=5;
var id=setTimeout("unuse()",1000);
function unuse()
{
status=count--;
if(count<0)
{
clearTimeout(id);
status="";
document.getElementById("Button1").disabled=false;
}
else
{
id=setTimeout("unuse()",1000);
document.getElementById("Button1").disabled=true;
}
}
</script>
</body> --------------------编程问答-------------------- 好使的,真好使,是项目中用的,保存后用把.txt改为.html就可以看到了。
<FORM name=agree action=reg.asp?action=apply method=post>
<INPUT type=submit value="请认真查看<服务条款和声明>(10 秒后继续)" name=agreeb>
</Form>
<SCRIPT language=javascript>
var secs = 10;
document.agree.agreeb.disabled=true;
for(i=1;i<=secs;i++) {
window.setTimeout("update(" + i + ")", i * 1000);
}
function update(num) {
if(num == secs) {
document.agree.agreeb.value ="同意并注册";
document.agree.agreeb.disabled=false;
}
else {
printnr = secs-num;
document.agree.agreeb.value = "请认真查看<服务条款和声明> (" + printnr +" 秒后继续)";
}
}
</SCRIPT> --------------------编程问答-------------------- NB --------------------编程问答-------------------- 只能JS做了 --------------------编程问答-------------------- octverve(炎之脉) 顶你`~~~~~~~~~~~~~~~~~~`` --------------------编程问答-------------------- 找个论坛注册页面 扒下来瞅瞅 --------------------编程问答-------------------- <script type="text/jscript">
var productList=null
var secs =10;
var wait = secs * 1000;
function show(url)
{
productList=window.open("Urlguess365.asp?url="+url);
divtime.innerHTML= "(10秒后显示)";
for(i = 1; i <= secs; i++) {
window.setTimeout("update(" + i + ")", i * 1000);
}
window.setTimeout("timer()", wait);
}
function update(num,value) {
if(num == (wait/1000))
{
}
else {
divtime.innerHTML="";
printnr = (wait / 1000) - num;
divtime.innerHTML= "(" + printnr + "秒后显示)";
}
}
function timer() {
if(productList==null || productList.closed){
alert("请不要关闭广告页面")
}else{
divtime.style.display='none';
divclose.style.display='none';
divshow.style.display='block';
}
}
</script>
效果页面:http://www.guess365.com/showvote.asp?id=21531 --------------------编程问答-------------------- //超简单:==========================
var n = 0;
function setEnable(){
n++;
if(n==5){
btn.disabled = true;
}else{
btn.value = "我同意("+(5-n)+")";
}
}
window.setTimeout(setEnable,1000); --------------------编程问答-------------------- 汗一个
保姆太多了,代码都写这么详细 --------------------编程问答-------------------- 这种代码满世界都是,其实知道怎么用setTimeout的都写的出来,万变不离其宗 --------------------编程问答-------------------- mark --------------------编程问答-------------------- 同意syeerzy的说法,其实找到类似网站后看看其网页的html源代码,找到js文件研究下自己也能写出来 --------------------编程问答-------------------- mark --------------------编程问答-------------------- var n = 0;
function setEnable(){
n++;
if(n==5){
btn.disabled = true;
}else{
btn.value = "我同意("+(5-n)+")";
}
}
window.setTimeout(setEnable,1000);
这个强! --------------------编程问答-------------------- 过来看一下,不发表任何意见 --------------------编程问答-------------------- 路过...学习...不发表意见 --------------------编程问答-------------------- LG --------------------编程问答-------------------- 路过...学习... --------------------编程问答-------------------- 方法真多。。。 --------------------编程问答-------------------- 学习了 --------------------编程问答-------------------- var n = 0;
function setEnable(){
n++;
if(n==5){
btn.disabled = true;
}else{
btn.value = "我同意("+(5-n)+")";
}
window.setTimeout(setEnable,1000);
}
不好意思,这样写才对。昨天把最后一句写到外面了,后来才发现。 --------------------编程问答-------------------- var n = 0;
function setEnable(){
n++;
if(n>=5){
btn.disabled = true;
return; //add
}else{
btn.value = "我同意("+(5-n)+")";
}
window.setTimeout(setEnable,1000);
} --------------------编程问答-------------------- 不要写这么详细吧, --------------------编程问答-------------------- <HTML>
<HEAD>
<script language= "javascript">
var n = 0;
function setEnable()
{
n++;
if(n==5)
{
btn.disabled = false;
btn.value = "我同意";
}
else
{
btn.value = "我同意("+(5-n)+")";
}
}
var time = window.setInterval("setEnable();stop();",1000);
function stop()
{
if (n>=5)
{
window.clearInterval(time);
}
}
</script>
</head>
<body>
<input type="button" id="btn" value="click me" disabled="true" onclick="javascript:window.location.href='http://www.google.com'">
</body>
</HTML> --------------------编程问答-------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm6</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript" type="text/javascript">
var intI = 0;
var objInterval;
function FunBegin(objI)
{
intI = objI;
objInterval = window.setInterval("FunEnd()",1000);
document.getElementById("bt_test").value = "倒计时5秒";
document.getElementById("bt_test").disabled = true;
}
function FunEnd()
{
if(intI > 0)
{
document.getElementById("bt_test").disabled = true;
document.getElementById("bt_test").value = "倒计时" + intI + "秒";
intI = intI - 1;
}
else
{
document.getElementById("bt_test").disabled = false;
document.getElementById("bt_test").value = "倒计时结束";
window.clearInterval(objInterval);
}
}
</script>
</HEAD>
<body>
<form id="WebForm6" method="post" runat="server">
<input id="bt_test" type="button" value="倒计时5秒" onclick="javascript:FunBegin(5);">
</form>
</body>
</HTML>
=================================================================
IE6、FF2.0下通过 --------------------编程问答-------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm6</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript" type="text/javascript">
var intI = 0;
var objInterval;
function FunBegin(objI)
{
intI = objI;
objInterval = window.setInterval("FunEnd()",1000);
document.getElementById("bt_test").value = "倒计时5秒";
document.getElementById("bt_test").disabled = true;
}
function FunEnd()
{
if(intI > 0)
{
document.getElementById("bt_test").disabled = true;
document.getElementById("bt_test").value = "倒计时" + intI + "秒";
intI = intI - 1;
}
else
{
document.getElementById("bt_test").disabled = false;
document.getElementById("bt_test").value = "倒计时结束";
window.clearInterval(objInterval);
}
}
</script>
</HEAD>
<body>
<form id="WebForm6" method="post" runat="server">
<input id="bt_test" type="button" value="倒计时5秒" onclick="javascript:FunBegin(5);">
</form>
</body>
</HTML>
=================================================================
IE6、FF2.0下通过
--------------------编程问答-------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm6</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript" type="text/javascript">
var intI = 0;
var objInterval;
function FunBegin(objI)
{
intI = objI;
objInterval = window.setInterval("FunEnd()",1000);
document.getElementById("bt_test").value = "倒计时5秒";
document.getElementById("bt_test").disabled = true;
}
function FunEnd()
{
if(intI > 0)
{
document.getElementById("bt_test").disabled = true;
document.getElementById("bt_test").value = "倒计时" + intI + "秒";
intI = intI - 1;
}
else
{
document.getElementById("bt_test").disabled = false;
document.getElementById("bt_test").value = "倒计时结束";
window.clearInterval(objInterval);
}
}
</script>
</HEAD>
<body>
<form id="WebForm6" method="post" runat="server">
<input id="bt_test" type="button" value="倒计时5秒" onclick="javascript:FunBegin(5);">
</form>
</body>
</HTML>
=================================================================
IE6、FF2.0下通过 --------------------编程问答-------------------- 学习一下!~ --------------------编程问答-------------------- 贴子烂,LZ也不结,你什么人啊?BS --------------------编程问答-------------------- 高手很多啊,学习了。楼主怎么不结贴呢? --------------------编程问答-------------------- octverve(炎之脉)
贴子烂,LZ也不结,你什么人啊?BS
贴子烂--帖子那里烂了?你天生就天才啊!你学1+1的时候不知道你是不是傻B啊!你说你傻B吧也不要紧,自己再家里傻,别出来傻,出来傻就是你的不对了.
LZ也不结--结不结管你易做图事啊?有空回家管管你老婆,看看是不是在偷男人,不该你管的事少他妈管,CSDN是你家的啊,你这种人就是易做图,以后少他妈的易做图,你要是在我跟前的话,我非扇你个B.
你什么人啊?---不管什么人,都轮不到你发表意见,等你老婆偷男人的时候,你就和你老婆说"你什么人啊".
BS--从我上面的话,就可以看出来我BS你 --------------------编程问答-------------------- 牛,都是JS高手,学习 --------------------编程问答-------------------- octverve(炎之脉) 的
真是好使 --------------------编程问答-------------------- zzfjfhwfnhti() 也不错 加个标记 --------------------编程问答-------------------- 为什么不管事啊? --------------------编程问答-------------------- 沉没按钮,收下了.
帮顶.
学习 --------------------编程问答-------------------- 无语 --------------------编程问答-------------------- netFrameWork007
乱咬人?
--------------------编程问答-------------------- 休眠 休眠期间 btn enabled =false
--------------------编程问答-------------------- 标记一下! --------------------编程问答-------------------- setTimeout() --------------------编程问答-------------------- <html>
<body>
<script type="text/javascript">
function Enabled()
{
document.getElementById("btn").disabled="";
}
window.onload=setTimeout(Enabled,5000);
</script>
<input type="button" value="Submit" id="btn" disabled="disabled" onclick="alert(1)" />
</body>
</html> --------------------编程问答-------------------- ]
--------------------编程问答-------------------- 按钮先直接设成禁用
在页面加载函数里 settimeout(A,5000)
A函数里把按钮禁用取消了 --------------------编程问答-------------------- 方法真的很多:
1、利用JS内的SetTimeOut();
2、利用获取当前时间的秒+5后,然后不断地和当前时间的秒进行比较,如果相等了就解除禁用;
3、利用Timer控件吧。 --------------------编程问答-------------------- <html>
<body>
<script type="text/javascript">
function Enabled()
{
document.getElementById("btn").disabled="";
}
window.onload=setTimeout(Enabled,5000);
</script>
<input type="button" value="Submit" id="btn" disabled="disabled" onclick="alert(1)" />
</body>
</html>
补充:.NET技术 , ASP.NET