<script type="text/javascript">
var rndKey;
function randomnum(num) {
var m = "";
for (var i = 0; i < num; i++)
{ var n = Math.floor(Math.random() * 10); m += n; } 解释{Math.random() * 6 生成0和6之间的随机小数,Math.floor(x)函数,返回小于等于x的最大整数}
return m;
}
function GetKey() {
var key = randomnum(4);
rndKey = key;
document.getElementById("CheckImgKey").value = key;
document.getElementById("CheckImg").src = "Login/ImgKey.aspx?key=" + key;{解释:SQJZ项目下的Login/ImgKey.aspx}
}
window.document.write("<input tabindex='3' name='UserKey' type='text' id='UserKey' class='input' size='5' style='width:95px;height:18px;' maxlength='4' /><input id='CheckImgKey' name='CheckImgKey' type='hidden' />");
window.document.write(" <img id='CheckImg' align='absmiddle' src='images/ImgKey.jpg' style='width:50px;height:22px;cursor:pointer;' onclick='GetKey();' alt='点击换一个'>");
GetKey();
$(function() {
window.setTimeout("ResetKey()", 1000); });
function ResetKey() {
$("#CheckImgKey").attr("value", rndKey);
}
</script>