Fix when unable to refresh the captcha image on some browsers

Close #1668