I'm trying to do an app where onclick on home button it comes to home page,but i want to make browser back button invisible or in hidden state using javascript .Is there any way to do that.
Asked
Active
Viewed 100 times
0
-
Possible duplicate of [how to stop browser back button using javascript](https://stackoverflow.com/questions/12381563/how-to-stop-browser-back-button-using-javascript) – Kévin Bibollet May 07 '19 at 09:41
-
You cannot make it invisible nor disable it. You can just alert. – Kévin Bibollet May 07 '19 at 09:42
-
6No, thankfully not. – BenM May 07 '19 at 09:42
-
2It sounds like you're trying to make a site full of annoying ads and trying to prevent users from leaving. – K. P. May 07 '19 at 09:45
-
@K.P. maybe, but maybe he / she just wants to prevent users from navigating using the back button to keep internal states of the wepapp – messerbill May 07 '19 at 09:46
1 Answers
0
window.onbeforeunload = function() { return "Your work will be lost."; };
will at least provide a warning, but it is not guaranteed because all browsers behave differently.
More information can be found here, how to stop browser back button using javascript

Greg Domorski
- 76
- 4