我有一个验证码图像的表单验证和一个javascript来刷新图像,如果它是不可读的用户。该脚本在Chrome中工作良好,但在Firefox中,它只在第一次工作,之后,虽然脚本运行,图像不刷新。图像SRC包括:
<?php echo "?rand=" . rand(); ?>
但是,尽管php工作正常,刷新仍然是不可操作的。
我已经检查了这个,这个,并尝试了许多建议-例如添加和删除no cache
元标签,将正文和头部标签更改为h:body
和h:head
。
许多建议(例如这里的建议)描述的代码情况与我的不同(在我的情况下,我使用php生成的图像)。
任何帮助都将非常感激。
<script type="text/javascript">
function refresh_captcha()
{
var img = document.getElementById('captchaimg');
img.src = 'captcha_code_file.php?rand=<?php echo(rand()); ?>';
document.getElementById ("captchaimg").src = img.src;
//alert("some alert.");
}
页面在这里
尝试使用这个,随机不是php,而是JS。
function refresh_captcha()
{
var img = document.getElementById('captchaimg');
img.src = 'captcha_code_file.php?rand=' + Math.random();
document.getElementById ("captchaimg").src = img.src;
//alert("some alert.");
}