Refresh Simple Captcha

回眸只為那壹抹淺笑 提交于 2019-12-05 11:31:24
javaghost
<script type="text/javascript">
    function reloadCaptcha(){
        var d = new Date();
        $("#captcha_image").attr("src", "/captcha_generator.jsp?"+d.getTime());
    }
</script>
   ...
<img id="captcha_image" src="/captcha_generator.jsp" alt="captcha image" width="200" height="50"/>
<img src="reload.jpg" onclick="reloadCaptcha()" alt="reload"width="40" height="40"/>

I don't remember how SimpleCaptcha works, but usually, you should simply change the 'src' attribute of you captcha <img>. Something like this on the onClick of your refresh button:

var img = document.getElementById('captcha_id');// captcha_id is the id attribute of your caprtcha img
img.src = 'Some new captcha url';
<script type="text/javascript">
    function reloadCaptcha(){
        var d = new Date();
        $("#captcha_image").attr("src", "captcha.php?"+d.getTime());
    } </script>

<img id="captcha_image" src="captcha.php" alt="captcha image" width="90" height="33"/> <img src="images/refresh.png" alt="reload" width="22" height="22" border="0" onclick="reloadCaptcha()" />
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!