//生成验证码
<?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语法请讲解一下,谢谢。
怪我咯2017-04-10 14:58:26
@Chobits 已经说了它的用途,这里自己再补充一点。
if(this.src!=this.src+'?'+Math.random)
这个if判断应该总是true的,所以this.src=this.src+'?'+Math.random()总是会执行。
应该直接去掉if(this.src!=this.src+'?'+Math.random)这个条件判断,毕竟这里没实际意义。
怪我咯2017-04-10 14:58:26
http://stackoverflow.com/questions/1077041/refresh-image-with-a-new-one-at-the-same-url
为了刷新图片不缓存