Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
43
rated 0 times [  47] [ 4]  / answers: 1 / hits: 21278  / 11 Years ago, wed, november 13, 2013, 12:00:00

Is there a cross-browser compatible way of forcing page refresh when clicking the navigator back button?



i am trying to access to actualised cookies :



i have a js setcookie function that record changes in a type selector



$( #type-select ).change(function() {             
var type = $(#type-select).val();
SetCookie(liste-voyage-type,type);
});


i'd like to retrieve that value when returning on this page, clicking the browser back button, using php



 if (isset($_COOKIE[liste-voyage-type]))
$type=$_COOKIE[liste-voyage-type];

More From » jquery

 Answers
23

I had a similar requirement in my project. You can do something like this:



For example, lets say there are two pages: page1 and page2



In Page1 do something like this:



<script>
if (sessionStorage.getItem(Page2Visited)) {
sessionStorage.removeItem(Page2Visited);
window.location.reload(true); // force refresh page1
}
</script>


And in page2:



<script>
sessionStorage.setItem(Page2Visited, True);
</script>


Now, it will force a page refresh on page1, whenever you click back button from page2.


[#74312] Tuesday, November 12, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
byron

Total Points: 616
Total Questions: 101
Total Answers: 91

Location: Reunion
Member since Wed, Apr 14, 2021
3 Years ago
byron questions
Wed, Jan 26, 22, 00:00, 2 Years ago
Sat, Jun 6, 20, 00:00, 4 Years ago
Thu, Nov 7, 19, 00:00, 5 Years ago
Wed, Sep 11, 19, 00:00, 5 Years ago
;