admin管理员组

文章数量:1410689

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

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

Share edited Apr 29, 2012 at 17:03 Knu 15.2k6 gold badges59 silver badges92 bronze badges asked Feb 10, 2011 at 18:56 CircusNinjaCircusNinja 2671 gold badge6 silver badges13 bronze badges 1
  • Check for cacheing headers on the mobile setups? Many (most? all?) mobile ISPs have transparent proxies that could be enforcing no-cache headers of some sort, forcing the remote devices to reload the pages and incur higher data charges ($$$kaching$$$) – Marc B Commented Feb 10, 2011 at 19:14
Add a ment  | 

3 Answers 3

Reset to default 2

Use:

    <a href="javascript:history.go(-1)">Back to Results</a>

ie not in "onclick" but in "href" - that's work

For Android, you need to enable javascript in the webview :

webView.getSettings().setJavaScriptEnabled(true);

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?

本文标签: androidWhy is javascripthistorygo(1) not working on mobile devicesStack Overflow