Fix Apple phone return not refreshed problem

Source: Internet
Author: User

Problem Description:

JS return to the previous page of implementation: 1) History.go (-1);

2) History.back ();

3) History.back (-1);

The first way to return to the previous page on the Apple phone does not refresh, resulting in the status of the previous page is not updated, the 23rd method did not experiment, it is estimated that the problem, the function of the Android phone is normal.

Workaround:

For example, there are now a.html and b.html , from a.html to b.html to operate,b.html in the operation changes to the state after the Back to a.html when the data is re-requested, the corresponding status can be updated.

1. Add a random number to the AJAX request URL in a.html

This method is available before the end of iOS system 9, but not in the app.

2. Spa (single page routing)

This method can solve the problem perfectly.

3, Window.location.href = './a.html '

This approach solves this problem, but it brings a new problem: Return to the Dead loop

4. Monitoring pageshow and pagehide methods

Feel this is the best way to change the page is not too big, just add the following code in JS

$ (function () {
var ispagehide = false;
window.addeventlistener (' Pageshow ', function () {
if (ispagehide) {
window.location.reload ();
                      }
               });
window.addeventlistener (' Pagehide ', function () {
ispagehide = true;
               });
          });


Fix Apple phone return not refreshed problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.