Skip to content Skip to sidebar Skip to footer

Window.history.length Maximum Value

Value of window.history.length is very important in our project to detect backbutton is clicked on browser. However I realized that window.history.length does not pass 50. How to s

Solution 1:

Depending on whether you need it to be persistent across sessions and surviving a clean of the user information (cache, localStorage, etc...) you might want to adopt different solutions.

One of the solutions could be to do something like this:

window.onpopstate = function(event) {
  var count = parseInt(localStorage.getItem('history-changes-count'), 10);
  localStorage.setItem('history-changes-count', ++count);
};

Note that onpopstate gets invoked only after a user action, it doesn't work if you modify the history programmatically.

More on the subject: https://developer.mozilla.org/en-US/docs/DOM/window.onpopstate

Solution 2:

It is possible to detect "Back Button Clicked" via iFrames. You can find the answer here.

Post a Comment for "Window.history.length Maximum Value"