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