Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
98
rated 0 times [  99] [ 1]  / answers: 1 / hits: 21507  / 13 Years ago, sun, january 1, 2012, 12:00:00

is there any way to create a button which will on click take you to previous page
and then refresh the page immediately? I use the following code to go back to previous page but it does not reload/refresh..



<input type=button value=Back onClick=javascript: history.go(-1)>


Thanks :)


More From » jquery

 Answers
12

The only way to refresh the loaded page would be to use window.location.reload() in the new page.



You could try getting the last URL using document.referrer (or by keeping a history of their page views in a cookie) and then adding something to the hash to make it like:



http://stackoverflow.com#didGoBack



Then, in javascript, check to see if that hash exists using window.location.hash and if so, reload the page. Note. the referrer won't be set unless they arrived at that page via a link.


[#88286] Friday, December 30, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
anyssaarielles

Total Points: 415
Total Questions: 107
Total Answers: 92

Location: Greenland
Member since Fri, Jul 31, 2020
4 Years ago
;