I am trying to build a website that has an exit button. Once the exit button is clicked, I need to navigate away from my current page to Google AND I need it so that my back button can't be pressed to find my webpage. How would I do this using Javascript?
Asked
Active
Viewed 46 times
1 Answers
1
You can use this piece of code to prevent going back:
window.onbeforeunload = () => { return "You cannot propagate back."; };

Ziad Ali
- 76
- 5