使用启动和停止按钮刷新时,计时器无需重新启动 [英] Timer without restarting when refreshed with start and stop button

查看:93
本文介绍了使用启动和停止按钮刷新时,计时器无需重新启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我需要一个带开始和停止按钮的倒数计时器。当我刷新它时,它不会重新启动。它会一直持续到零。请帮我。我怎样才能做到这一点?认罪。谢谢你的答案

Hello guys, i need a countdown timer with start and stop button. and when i refresh it, it will not restart. it just continue until it reach zero. Please help me. how can i do this? pleas. thank you for answers

推荐答案

你有几个选择。例如,即使刷新,cookie也可用于在页面(或同一页面)之间存储数据。您只需要存储计时器的开始时间。您可以计算从当前时间减去开始时间之间的时间。因此它将具有正确的倒计时值,即使用户浏览到另一个站点并在一段时间之后返回。



有关在浏览器中保存数据的更多信息,请查看此处:

http://www.sitepoint.com/html5-browser-storage-past-present-future/ [ ^ ]



祝你好运!
You have several options. For example cookies can be used to store data between pages (or same page) even when refreshed. You only need to store the start time of the timer. You can calculate the time between from the current time minus the start time. So it will have the correct countdown value, even if a user browses to another site and comes back some time later.

For more info on persisting data in the browser, have a look here:
http://www.sitepoint.com/html5-browser-storage-past-present-future/[^]

Good luck!


这篇关于使用启动和停止按钮刷新时,计时器无需重新启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆