在网页中显示一个灰色按钮,倒计时30秒后方可用这个按钮。请问代码怎么写?
发布网友
发布时间:2022-05-18 08:55
我来回答
共2个回答
热心网友
时间:2022-05-18 10:24
<form id="form1" name="form1" method="post" action=""><input id="SB" style="width:100;height:100" onClick="GOGO();" type="button" name="Submit" value="我同意" /></td>
<script language="javascript">
document.form1.Submit.disabled = true;
var speed = 1000; //速度
var wait = 10; //停留时间
function updateinfo(){
var submitbnt = getCookie("submitbnt")
if(submitbnt==1){
document.form1.Submit.value = "我同意";
document.form1.Submit.disabled = false;
return;
}
if(wait == 0){
document.form1.Submit.value = "我同意";
document.form1.Submit.disabled = false;
setCookies("submitbnt",1)
}
else{
document.form1.Submit.value = "\n\n 我同意\n\n"+wait;
wait--;
window.setTimeout("updateinfo()",speed);
}
}
function setCookies(cookieName,cookieValue){
var today = new Date();
var expire = new Date();
expire.setTime(today.getTime() + 3600000 * 356 * 24);
document.cookie = cookieName+'='+escape(cookieValue)+ ';expires = '+expire.toGMTString() + ";path= / ;";
}
function getCookie(cookieName){
var theCookie=''+document.cookie;
var ind=theCookie.indexOf(cookieName);
if (ind==-1 || cookieName=='') return '';
var ind1=theCookie.indexOf(';',ind);
if (ind1==-1) ind1=theCookie.length;
return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}
updateinfo();
</script>