0👍
You can use window.history.length
to track if history stack still has item(s) (length > 0). However this approach only work when user start afresh from a new tab/window. If a user uses existing tab with some browsing history, this method will not work.
The other way you can do is to mimic the history stack for your own app using sessionStorage
. Whenever user navigate to a new page, you will push a record in sessionStorage
. And when user click your back button you will pop the a record from sessionStorage
. So you can check the sessionStorage
is empty and a click to back button will trigger an alert or some sort.
- [Vuejs]-How to reuse a first template inside a second div
- [Vuejs]-How to make sense of, and then effectively use the console warnings and errors in vue?
Source:stackexchange.com