Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Count number of pages in History

IS there is any way to check how many pages are present in Dom/cache?

In my application there are several pages, If any time suppose session expires then server gives me response code say-1. I check response code every time and if it is -1, Then I have to show index page to user for that I am doing this:

window.history.go(-4);

But in above case I had given value as -4 because here I know that there are 4 pages in Dom, But at runtime Ihow I came to know how many pages are present in DOm?

Any help/suggestion will be appreciated. Thanks in advance.

like image 201
PPD Avatar asked Nov 24 '25 10:11

PPD


1 Answers

Try this:

 window.history.length //4

Reference: https://developer.mozilla.org/en-US/docs/DOM/window.history

length Integer Read-only. Returns the number of elements in the session history, including the currently loaded page. For example, for a page loaded in a new tab this property returns 1.

like image 177
Esailija Avatar answered Nov 25 '25 23:11

Esailija