半小时倒计时
我如何为用户设置一个倒计时时间,让用户看到每半小时倒计时一次。例如,如果是 10:05,我希望它显示还剩 25 分钟的倒计时。我想它需要耗尽服务器时间。感谢您的帮助!
另外,是否可以在倒计时结束时刷新页面,以便用户可以在接下来的半小时内看到新页面?
**编辑:假设他们在 9:55 加载页面。我希望倒计时显示还剩 5 分钟。然后,一旦 10:00 到来,我希望页面刷新,以便倒计时可以再次显示 30 分钟。
How would I make a countdown time for users to see that would countdown to every half hour. For example, if it were 10:05, I would want it to display a countdown that had 25 minutes remaining. I guess it would need to run off of the server time. Thanks for your help!
Also, would it be possible to refresh the page at the end of the countdown so the user could see the new one for the next half hour?
**Edit: Say they load the page at 9:55. I would like the countdown to display 5 mintues remaining. Then as soon as 10:00 were to come, I would like the page to refresh so that the countdown could display 30 minutes again.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个执行此操作的函数:
这是 JavaScript,因此不涉及服务器。要显示连续倒计时,您可以这样做(假设您有一个 ID 为“倒计时”的元素):
或者,用(非标准)简写:
Here's a function that does that:
That's JavaScript, so there's no server involved. To display a continuous countdown, you could do this (assuming you have an element with an ID of "countdown"):
Or, in (non-standard) shorthand: