当 JavaScript 应用程序崩溃时,如何自动重新启动它?
我有兴趣在无人值守的网络浏览器中运行幻灯片。我宁愿它没有崩溃。我应该如何确保 javascript 应用程序继续运行或浏览器崩溃时重新加载主页?
I am interested in running a slideshow in an unattended web browser. I would rather it didn't crash. How should I make sure the javascript application continues to run or the browser reloads the home page when it crashes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
准备一个框架集,其中一个隐藏框架,另一个是您的实际内容框架。在隐藏帧中连续运行 setTimeout,它会不时被“内容”帧重置。假设隐藏框架中的 setTimeout 为 20 秒,让内容框架每隔 10 秒左右重置该超时 (clearTimeout)。如果未收到重置(内容框架已崩溃),则强制从隐藏框架重新加载内容框架。
Prepare a frameset with one hidden frame, and your actual content frame as the other. Have a setTimeout running continuously in the hidden frame, which gets reset by the "content" frame from time to time. Lets say that the setTimeout in the hidden frame is 20 seconds, have the content frame reset that timeout (clearTimeout) every 10 seconds or so. If no reset is received (content frame has crashed), force reload the content frame from the hidden frame.