验证码单击刷新问题



 //生成验证码
<?php
    public function showVerify(){

        $data = array(
            'fontSize'  =>  30,
            'length'    =>  3,  
            'useNoise'  =>  true,
            'useCurve'  =>  false,
        );
        $Verify = new \Think\Verify($data);
        $Verify->entry();

    }


在另一处调用showVerify()


 <img src="__CONTROLLER__/showVerify" width="60" onclick="if(this.src!=this.src+'?'+Math.random) this.src=this.src+'?'+Math.random()"/>


请问:


 if(this.src!=this.src+'?'+Math.random) this.src=this.src+'?'+Math.random()

这句javascript语法请讲解一下,谢谢。

thinkphp JavaScript

wann. 9 years, 2 months ago

如果验证码变了,那么显示新的验证码

水无月留姬 answered 9 years, 2 months ago

死了才逍遥 answered 9 years, 2 months ago

//问题补充
//在另一处调用showVerify()
<html>

</html>

紫色Sòrγy answered 9 years, 2 months ago

@Chobits 已经说了它的用途,这里自己再补充一点。


 if(this.src!=this.src+'?'+Math.random)

这个if判断应该总是true的,所以this.src=this.src+'?'+Math.random()总是会执行。
应该直接去掉if(this.src!=this.src+'?'+Math.random)这个条件判断,毕竟这里没实际意义。

器材的境界 answered 9 years, 2 months ago

Your Answer