How to check if previous page has a specific URL before moving back in JavaScript?

436 Views Asked by At

After a button is clicked in my app I use window.history.back() but I would like to write in some logic to check what that back history (previous page URL) is and see if it was I expect before executing that back function. If the previous page URL is not what I am expecting I want to redirect the user to my homepage.

Is there a good way to do this?

0

There are 0 best solutions below