2

I am using history.pushState(stateObj, "page", url); functionality in one of the pages and it works fine for desktop based browser but same fails to work when i view the website on mobile devices for example i tried same on iphone 6 safari & chrome.

I am not sure if i have to use history.js to support mobile browsers as this script is usually to support old browsers.

What happens actually is it creates a back history but always shows the same page even it you navigate history by -1 or -2. While same works fine on desktop browsers. May be issue could be due to limited cache of mobile browsers

Learning
  • 19,469
  • 39
  • 180
  • 373
  • Can you describe "fails to work"? – guest271314 Jun 19 '16 at 04:33
  • What happens actually is it creates a back history but always shows the same page even it you navigate history by -1 0r -2. While same works fine on desktop browsers. May be issue could be due to limited cache of mobile browsers – Learning Jun 19 '16 at 04:34
  • Interesting. Curious if http://stackoverflow.com/a/30144363/ returns expected result at mobile browser? – guest271314 Jun 19 '16 at 04:55
  • I tried same on Samsung default android browser and it worked fine. so issue seems to be with Iphone – Learning Jun 19 '16 at 05:50
  • If I'm not mistaken, history.pushState() will not cause a page reload. It will update the URL and or hash and that is all. If you want to change the page when the Hash changes subscribe to the hashchange event and do location = 'yourfile.hmtl' or something. Idk if this is what you're looking for though. If you're not looking at the hash and just strictly the foo.com/one part of the URL you'll have to poll [something].pathname to see when it changes much like the hashchange stuff. There might be an event you could subscribe to for the URL part but idk it off the top of my head – Coty Embry Jun 19 '16 at 07:43

0 Answers0