Jacklovely

导航

 

用“换一张”来控制验证码刷新,js脚本怎么写

宏朋雄 | 浏览 3663 次  2012-06-11 22:41
2012-06-12 01:49 最佳答案
 
<img src=“验证码文件路径"  onclick = "this.src='验证码路径?'+Math.random()"/>
其他同理!
 

jiangxibaiyi 

采纳率:55% 来自团队:IT精英俱乐部 擅长: 其他社会话题 夫妻 博彩

 

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册</title>
</head>
<body>
    <form action="" method = "get">
        用户名
        <input type="text">
        密码
        <input type="text">
        <img src="yanzhengma.php" id = "yanzhengma"></form>
    <img src="yanzhengma.php">
    <?php 
    $var = '<script type="text/javascript">
    onload = function(){
        var yanzhengma = document.getElementById("yanzhengma");
        yanzhengma.onclick = function(){
            this.src = "yanzhengma.php?"+Math.random();
        };
    }
    
</script>';
    echo $var ?>
</body>
</html>

 

posted on 2016-11-09 19:34  Jacklovely  阅读(277)  评论(0编辑  收藏  举报