Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to detect page change and prompt user (like window.onbeforeunload)? #553

Open
ryangriggs opened this issue Jan 23, 2020 · 1 comment

Comments

@ryangriggs
Copy link

Example: a form that the user fills in. Then they attempt to navigate away from the page. How can we hook the "onbeforeunload" action and prevent page transition unless user approves loss of changes? window.onbeforeunload doesn't seem to fire in these page transitions.

@viktorcitaku
Copy link

I'm facing an issue for which I tried to solve with the window.onbeforeunload event, but without success. So basically I have two simple pages that I can navigate to, and the page.js adds to the URL a path based on the current page, in my case, it is the /about page. Now, whenever I hit the refresh button, the action is recognised as an HTTP request leading to page not found. That's why I am trying to intercept this HTTP call with window.onbeforeunload event, which seems not to work.

I've searched for open issues, and I found the following question: #373 . This question doesn't help me in my case but might help you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants