Search code examples
loopsbrowserinfinite

Javascript Browser History


I am writing an application that has turned into an infinite loop. It starts out on Page A, it then redirects to Page B on button press which automatically redirects to Page A again after running some JavaScript behind the scenes.

This turns into an infinite loop. Is there any way to check the browser history from two pages ago? If I can do that I can check that URL with the current browser window URL and stop the redirect functionality on the button press of Page A if the two are equal.

Any other ideas would be helpful as well.


Solution

  • you would have to custom write something like tracking in a cookie... it appears that you can't get history of a url back 2 steps due to security reasons. see here: how can i get the url from history.go(-2)