87,921
社区成员
发帖
与我相关
我的任务
分享
var IsVerifyCodeFocused;
var IsTxtVerifyCodeFocused;
$("#txtVerifyCode").focus(function () {
IsTxtVerifyCodeFocused = true;
if (document.getElementById("divVerifyCode")) {
$("#divVerifyCode").fadeIn();
}
else {
var imgVerifyCode = $("<div id='divVerifyCode' style='height:55px;background-color:#dff6c6;border:1px solid #bdde98;text-align:center;line-height:20px'><img alt='验证码' id='imgCode' src='BLL/VerificationCode.ashx' title='看不清楚,换一张' height='30px' width='70px' style='border:1px solid #aecaca;cursor:pointer;' /><br/><span id='spanChangeVerifyCode' class='ChangeVerifyCode'>点击更换验证码</span></div>");
$("body").append(imgVerifyCode);
var offset = $("#txtVerifyCode").offset();
var width = $("#txtVerifyCode").width();
var top = offset.top - $("#divVerifyCode").height() - 1;
var left = offset.left;
$("#divVerifyCode").css({ 'position': 'absolute', 'width': width + 'px', 'top': top + 'px', 'left': left + 'px' }).focus(function () {
IsVerifyCodeFocused = true;
}).blur(function () {
IsVerifyCodeFocused = false;
setTimeout("hideVerifyCode()", 0);
});
$("#imgCode").click(function () {
this.src = 'BLL/VerificationCode.ashx?tmp=' + new Date().getTime().toString(36);
});
$("#spanChangeVerifyCode").click(function () {
$("#imgCode").attr("src", "BLL/VerificationCode.ashx?tmp=" + new Date().getTime().toString(36));
}).mouseenter(function () {
this.className = 'ChangeVerifyCode ChangeVerifyCodeHover';
}).mouseout(function () {
this.className = 'ChangeVerifyCode';
});
}
}).blur(function () {
IsTxtVerifyCodeFocused = false;
setTimeout("hideVerifyCode()", 0);
});
function hideVerifyCode() {
if (document.getElementById("divVerifyCode")) {
if (IsVerifyCodeFocused || IsTxtVerifyCodeFocused) {
return;
}
$("#divVerifyCode").fadeOut();
}
}