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 🙂
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.hashand if so, reload the page. Note. the referrer won’t be set unless they arrived at that page via a link.