<?xml version="1.0" encoding="UTF-8" ?>
<!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"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head xmlns:h="http://java.sun.com/jsf/html">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>登录控制</title>
<script>
//<![CDATA[
//var bt = document.getElementById('rulesubmit');
var bt;
var wait
var str
function waitmit(secs,tmp) {
wait = secs * 1000;
bt=tmp;
str = tmp.value;
bt.value = str+"(" + secs + ")";
bt.disabled = true;
for ( var i = 1; i <= secs; i++) {
window.setTimeout("update("+i+")", i * 1000);
}
window.setTimeout("timer()", wait);
}
function update(num) {
if (num == (wait / 1000)) {
bt.value = str;
} else {
var printnr = (wait / 1000) - num;
bt.value = str+"(" + printnr + ")";
}
}
function timer() {
bt.disabled = false;
bt.value = str;
}
//]]>
</script>
</h:head>
<body>
<h:commandButton value="修改" onclick="waitmit(9,this);"></h:commandButton>
</body>
</html>
自己封装的js秒读功能,欢迎大家改善。