为什么是 javascript:history.go(-1);无法在移动设备上工作?
首先,一些背景知识:
我有一个向用户呈现搜索页面(html 表单)的应用程序。填写标准并单击“搜索”按钮后,结果将显示在标准部分下方。在结果列表中,您可以通过单击将您带到新页面的链接来查看单个结果的详细信息。在详细信息页面中,我添加了一个“返回结果”链接,如下所示:
<a href="#" onclick="history.go(-1);return false">Back to Results</a>
这在桌面上的 IE8/9、Safari、Firefox 和 Chrome 中效果很好。但是,它无法在我的 Android 手机、Android 模拟器或 iPhone 3G 上运行。我应该注意到,当我使用桌面上的链接时,我会立即返回到似乎是带有结果的搜索页面的缓存副本,并且我被放置在结果中的相同滚动位置。在移动设备上,页面似乎从服务器重新加载,我的搜索条件消失,并且没有结果。
如果有人对从哪里开始寻找解决方案有任何想法,我将非常感激!我还可以根据需要提供更多详细信息。
谢谢你和问候, 中国
First, some background:
I have an application which presents a search page (html form) to the user. Once criteria have been filled out and the Search button is clicked, results appear beneath the criteria section. In the list of results, you can view the detail of an individual result by clicking a link which takes you to a new page. Within the detail page, I have included a Back to Results link like so:
<a href="#" onclick="history.go(-1);return false">Back to Results</a>
This works great in IE8/9, Safari, Firefox and Chrome on the desktop. However, it does not work on my Android phone, my Android emulator or the iPhone 3G. I should note that when I use the link on the desktop I am immediately returned to what seems to be a cached copy of my search page with results, and I'm placed at the same scroll position within the results. On the mobile devices, it appears as though the page reloads from the server, my search criteria disappear, and there are no results.
If anyone has any ideas on where to start looking for a solution, I would really appreciate it! I can also provide more detail as necessary.
Thank you and regards,
CN
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用:
即不在“
onclick
”中,而是在“href
”中 - 这就是工作Use:
ie not in "
onclick
" but in "href
" - that's work对于 Android,您需要在 webview 中启用 javascript:
For Android, you need to enable javascript in the webview :
您使用什么方法将过滤器传递到搜索页面?发布还是获取?
如果您使用的是 POST,那么您必须在过滤器返回时重新提交过滤器,否则您的页面将没有任何可过滤的内容。
尝试切换到 GET 并查看是否有效。
我认为重要的区别是它正在工作(即向您发送回页面),但您的移动设备没有重新发布您的表单字段?
What method are you using to pass filters to your search page? POST or GET?
If you're using a POST then you would have to resubmit your filters when they go back, otherwise your page won't have anything to filter on.
Try switching to a GET and see if that works.
I think the important distinction is that it is working (i.e. sending you back a page), but your mobile device isn't reposting your form fields?