读书人

无刷新更换验证码图片quot;onclick=quot;docum

发布时间: 2012-09-16 17:33:16 作者: rapoo

无刷新更换验证码图片"onclick="document.getElementById('ImgCode').src='../VerifyCode.aspx'"无效
直接
function randomCode2()
{
document.getElementById("ImgCode").src="../VerifyCode.aspx";
}
的话无效,图片怎么也不变
必须要分成2部分
function randomCode()
{
document.getElementById("ImgCode").src="";
}
function randomCode2()
{
document.getElementById("ImgCode").src="../VerifyCode.aspx";
}
先按一次,让src变成"",在按另外一个按钮,src="../VerifyCode.aspx";才能显示出来,请问是为什么呢?

[解决办法]
缓存的原因

JScript code
function randomCode2() {     document.getElementById("ImgCode").src="../VerifyCode.aspx?r="+Math.random(); } 

读书人网 >asp.net

热点推荐