link_to_function“javascript:history.back()”无法在谷歌浏览器中工作
处理一些动态页面,特别是我们为用户提供个人资料页面。然而,他们有多种路线可以到达这些页面,因此为后退按钮设置特定路线是不切实际的。
这是我的代码:
<%= link_to_function "Back", 'javascript:history.back()', { :class => "button-back" } %>
它生成这个 html:
<a href="#" class="button-back" onclick="javascript:history.back(); return false;">Back</a>
这在 IE 和 Firefox 中工作,但在 Chrome 中不起作用......什么给出了?我查看了其他类似的堆栈问题,但它们都不是特定于浏览器的,根据它们,这应该可行。任何帮助将不胜感激。
编辑: 经过进一步测试,发现真正的问题是,这在 chrome 中可以工作,但当我将页面放入 Iframe 并尝试使用按钮在 chrome 扩展内部导航时,它不起作用。我这样做的原因是因为我们根据浏览器在不同的应用程序/扩展/工具栏中跨浏览器使用这些页面。除了我们的 chrome 扩展之外,它可以在所有这些中工作。
Working on some dynamic pages and specifically we have profile pages for users. However there are several routs for them to get to these pages so its not practical to set up a specific rout for the back button.
here is my code:
<%= link_to_function "Back", 'javascript:history.back()', { :class => "button-back" } %>
and it generates this html:
<a href="#" class="button-back" onclick="javascript:history.back(); return false;">Back</a>
this is working in IE and Firefox but not Chrome....What gives? I have looked at the other stack questions that are similar but none of them are browser specific and according to them this should work. Any help would be appreciated.
Edit:
After further testing it turns out the real problem is that this is working in chrome but is not working when I drop the pages into an Iframe and try and use the button to navigate inside of a chrome extension. The reason I am doing this is because we are using these pages cross browser in different apps/extensions/toolbars depending on the browser. Its working in all of them except our chrome extension.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
javascript:
协议用于 href,而不是 onclick。如果你取出javascript:
它可能会起作用:但对我来说奇怪的是 IE 和 Firefox 接受这一点..
The
javascript:
protocol it for hrefs, not for onclicks. If you take out thejavascript:
it might work:It's strange to me that IE and Firefox accept that though..