在没有地址栏或键盘的情况下如何从 Rails Kiosk 错误页面返回主页
我在 Heroku 上托管了一个 Rails 应用程序。它在 Kiosk 模式下的 Google Chrome 触摸屏客户端上运行,因此没有浏览器 Chrome 或键盘。每个信息亭的登录/主页都不同。
错误页面是静态资源,因此我必须使用 Javascript 来完成此操作。如果出现错误,我想显示一个按钮,让用户返回主页。
我不能只使用后退按钮脚本,因为可能会出现多个错误。我考虑过使用 localstorage
来存储对主页的引用,但错误页面是从不同的域提供的,因此它们无法访问。
有什么想法吗?
编辑: 如果我将浏览器的主页设置为该特定信息亭,则这在 Firefox onClick="window.home();"
中有效。但 Chrome 显然不支持。有没有什么方法可以存储任何域都可以在每个浏览器/信息亭访问的某种变量。
Im hosting a rails app on heroku. It runs on the client on a touchscreen with Google Chrome in Kiosk mode, so no browser chrome or keyboard. The login/home page is different for every kiosk.
Error pages are static assets, so I'll have to do this with Javascript. If there is an error I want to display a button that will let the user get back to the home page.
I can't just use a back button script b/c of the potential for multiple errors. I thought about using localstorage
to store a reference to the home page, but the error pages are served from a different domain so they wont have access.
Any ideas?
Edit:
This works in Firefox onClick="window.home();"
If I set the browser's home page to that particular kiosk. But apparently isn't supported in Chrome. Is there any way to store some kind of variable that any domain can access on a per browser/kiosk basis.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你把这件事搞得太难了。您已经将需要返回的信息存储在“本地存储”中 - 浏览器历史记录.只需使用 javascript 查看历史记录并根据需要返回即可。
至于返回主页,主页不是一个众所周知的URI吗?
回家
出了什么问题?更新
主页不是永远是历史上的第一页吗?您似乎是在说,您想要返回一个不知道基本 URI、不知道如何到达当前位置、也不知道从哪里开始的页面。
我想您可以将您想要进入的位置放入 cookie,但如果您甚至不知道基本 URI,您将如何检索它?
我开始认为真正的答案是“你需要重新考虑你的设计,有一些严重错误。”
I think you're making this too hard. You already have the information you need to go back stored in "local storage" -- the browser history. Simply use javascript to look at the history and go back as far as you need.
As far as returning to the home page, isn't the home page a well known URI? What's wrong with
<a href="http://example.com/index.html">go home</a>
?Update
Isn't the home page always going to be the first page in the history? You seem to be saying that you're in a situation where you want to return to a page for which you don't know the base URI, don't know how you got where you are, and don't know where you started.
I suppose you could put the place you'd like to go into a cookie, but if you don't even know the base URI, how would you retrieve it?
I'm beginning to think the real answer is "you need to rethink your design, there's something deeply wrong."