自分が使える上のJS 3つ(ネット収集)

2846 ワード

1、提出ボタンのカウントダウン効果
<FORM name=bbrules action= method=post>
<INPUT style="HEIGHT: 23px" type=submit value="   " name=rulesubmit> 
<INPUT style="HEIGHT: 23px" onclick=javascript:history.go(-2); type=button value=    name=return> 
</FORM></CENTER>
<SCRIPT language=javascript>
var secs = 9;
var wait = secs * 1000;
document.bbrules.rulesubmit.value = "   (" + secs + ")";
document.bbrules.rulesubmit.disabled = true;
for(i = 1; i <= secs; i++) {
window.setTimeout("update(" + i + ")", i * 1000);
}
window.setTimeout("timer()", wait);
function update(num, value) {
if(num == (wait/1000)) {
document.bbrules.rulesubmit.value = "   ";
} else {
printnr = (wait / 1000)-num;
document.bbrules.rulesubmit.value = "   (" + printnr + ")";
}
}
function timer() {
document.bbrules.rulesubmit.disabled = false;
document.bbrules.rulesubmit.value = "   ";
}
</SCRIPT>
2、カウントダウン効果
<script>
  var Time = 5;
  var h,m,s; 
  var t = setInterval("e()",1000);
function e()
  { Time -= 1;
    h = Math.floor(Time/3600);
	m = Math.floor((Time-h*3600)/60);
	s = Time-m*60;   
    
	if (Time==0) {clearInterval(t);}   
	time.innerText =s;
  }
</script>
<span id=time></span>
もっと具体的なのは:
http://www.hubro.net/item/539/
3、返信後自動ジャンプ
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<title>    </title> 
<script type="text/javascript" language="javascript" > 
window.onload = initCountDownRedirector; 
function initCountDownRedirector(){ 
var x = document.getElementById("TimeCountNum"); 
if(!x) return; 
var t = x.innerHTML; 
window.setTimeout("countDownRedirector()",1000); 
} 
function countDownRedirector(){ 
var x = document.getElementById("TimeCountNum"); 
if(!x) return; 
var t = x.innerHTML; 
if(t > 0 ){ 
t--; 
x.innerHTML = t; 
window.setTimeout("countDownRedirector()",1000); 
}else{ 
window.location = x.title; 
} 
} 
</script> 
</head> 
<body> 
       ,<span id="TimeCountNum" class="B" title="/showThread.htm">3</span> 
       ... 
</body> 
</html>