sangrila B
sangrila B

Reputation: 584

HTML5 history API on iOS Chrome

For testing purposes I want to populate the history with a number of entries. More precisely I want to add X items to kind of disable the backbutton of the browser, since even if the user is clicking X times, he will stay on the same page.

I'm doing this the following way:

(function (){
   for (var x = 0; x < 10; x++) {
     history.pushState(null, document.title, location.pathname);    
   }        
}());

So when the page is being loaded 10 elements of the current page are injected into the history. This approach works on all browsers that support the history API except Chrome on iOS!!!

Using the above code, Chrome on iOS (7 to 10) does some really weird things:

Safari and every other iOS browser do what I want them to. What am I doing wrong?

Upvotes: 21

Views: 1930

Answers (1)

ShilpeshAgre
ShilpeshAgre

Reputation: 291

For chrome on iOS native history.pushState is overidded by additional extension, if you alert(history.pushState) you can see it is not native code as we see on other browsers

see below polyfills may help you,

  1. HTML5-History-API

  2. history.js

Upvotes: 2

Related Questions