Javascript 事件(如 onload)重复 - 如何停止?
我的网站上运行了一个“介绍”,但我不希望它在一定时间内重复。
您究竟如何设置和定义 cookie(或者是否有更好的解决方案),以每天/会话/每周运行一次等?
I got an "intro" running on my site, but I don't want it to repeat for a certain amount of time.
How exactly do you set and define a cookie (or is there any better solution), to run something once a day/session/week, etc?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将 cookie 设置为从现在起一天/一周到期,以处理“每天一次、每周一次”的情况。我不知道“一次会话” - 如何定义“会话”以及它何时开始/结束?
请参阅 Stackoverflow -如何将 cookie 设置为1 小时后过期
You could set the cookie to expire one day/week from now to handle "once a day, week" scenarios. I don't know about "once a session" - how do you define a 'session' and when does it begin/end?
See Stackoverflow -how to set cookie to expire in 1 hour
设置 cookie 是最兼容的方法。
请参阅 MDC
document.cookie
文档了解完整的故事。Setting a cookie is the most compatible way to do this.
See the MDC
document.cookie
docs for the full story.