日期:2014-05-17  浏览次数:20562 次

无刷新更换验证码图片"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(); 
}