On my website, I would like to disable the browser's back button and key so that a user cannot go back to the previous page.
I was taking an online exam in which a message box was displayed when the BACK button was clicked. I don't know if the coding is done in some other language but the message box popped up very quickly as soon I pressed the BACK button.
Additionally, I would like to disable the F5 key to prevent a user from refreshing their browser, perhaps they can be both done in a similar manner using JavaScript?
JavaScript:history.go(-1)
and then make an alert. — arfinatorlocation.replace()
function to get rid of the back button (only for your site). If you are using strictly HTML and JavaScript, that's the way to go. If you are using PHP, ASP, or CGI to process forms, then you need to rewrite your scripts to handle the back button or refresh instead of trying to prevent them. — ScienceOfSpock