In my application i want to disable browser back button. And redirect my page to another page if user clicks refresh button present in the browser.
Loading
In my application i want to disable browser back button. And redirect my page to another page if user clicks refresh button present in the browser.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Tuhin PaulPosted May 13, 2023, 3:16 AM
You can disable the browser back button and redirect the user to another page if they click the refresh button by using the following code:
This code will disable the browser back button by pushing the current page to the browser's history stack. When the user clicks the back button, the page will be restored from the history stack instead of going back to the previous page. The code will also redirect the user to a new page if they click the refresh button. This is done by listening for the beforeunload event and returning a string that tells the browser to redirect the user to the new page. You can modify this code to fit your specific needs. For example, you could add a message to the beforeunload event to warn the user that they are about to be redirected.
Deepak RawatPosted May 12, 2023, 10:55 AM
Vishal YelvePosted Mar 24, 2023, 7:29 AM
Try this,
Vishal JoshiPosted Mar 24, 2023, 7:27 AM
Hello Gopi
There are different ways to achieve the requirement.
Sample code to disable back button programmatically
Thanks
Raj BhattPosted Mar 24, 2023, 6:39 AM
You can try below code: