验证码重载和动画图标同步问题
我想在我的网站中创建验证码。我将尝试描述我想如何做到这一点。请参阅下面的代码:
<img src=”captcha_img.png”> <img src=”reload.png”> <a href=”..”>Reload Captcha Image</>
我想要做的是,单击“重新加载验证码图像”链接,然后使用 JavaScript 将第一个 img 标签的内容更改为新的验证码图像,同时更改reload.png 到 reload.gif,这是我希望在处理新的验证码图像时持续的动画。我想在新的验证码图像加载图像的同时将 reload.gif 动画更改回 reload.png 静态图像。问题是验证码图像是由 PHP 的 GD 库生成的,我不知道创建新图像需要多少时间。 请帮助我能够同步。也许有一个很好的方法来做这种事情……
谢谢!
I want to create a captcha in my website. I will try to describe how I want to do that. See the code below please:
<img src=”captcha_img.png”> <img src=”reload.png”> <a href=”..”>Reload Captcha Image</>
What I want to do is, to click on “Reload Captcha Image” link and with JavaScript change the content of the first img tag to a new captcha image, and simultaneously to change reload.png to reload.gif which is and animation that I want to last as much as the new captcha image is being processed. And I want to change back the reload.gif animation to the reload.png static image, right the same time when the new captcha image has been load image. The problem is that the captcha image is being generated by GD library of PHP, and I don’t know how much time that will take to create a new image.
Please help me to be able to synchronize. May be there is a good approach for doing this kind of things…
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在图像上使用
onload
事件,以准确了解新的验证码图像何时加载到浏览器上,我将 ID 添加到您的标记中:然后在您的代码中,连接事件处理程序:
You can use the
onload
event on the image, to know exactly when your new captcha image has been loaded on the browser, I added IDs to your markup:Then in your code, you connect the event handlers: