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.
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.