Going Back and Refreshing Page
The page that one of my back button navigates to requires some JavaScript code to run to hide div until a button is pressed. Essentially, what I needed was to be able to go back while having the page I’m going back to reload. Unfortunately, simply using history.go(-1) takes me back a page but loads it from cache. I’m not sure if it’s the iPhone/Mobile Safari that I’m testing on, but none of the following meta tags worked:
<meta http-equiq="Pragma" content="no-cache"> <meta http-equiv="Expires" content="-1"> <meta http-equiv="Cache-Control" content="no-cache">
So I scoured Google for a while until I stumbled upon a solution. There’s a call to get the URL of the last page. Then all I had to do was replace window.location with the URL.
var lastPage = document.referrer; window.location.replace(lastPage);
Pretty basic, but it works if you need to go back and and refresh a page. No messing around with cache, cookies, sessions, what have you.
