点击超链接更换验证码

废话不多说,直接上代码

<img class="yzm_img" id='imgVcode' src="<s:url value='/user/getCommonCode'/>" />

<input name="inputCommonCode" type="text" id="txtVerifyCode"    class="yzm_input"/>

<a οnclick="change()" href="" >看不清楚?换个图片</a>

<script type="text/javascript">
    function change(){
        document.getElementById("imgVcode").src="<s:url value='/user/getCommonCode'/>?t="+Math.ramdom();
    }
</script>

因为客户端浏览器会缓存URL相同的资源,所以可以使用传递随机数或者时间戳来重新请求。

发布了26 篇原创文章 · 获赞 9 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/wazk2008/article/details/81868413