Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to completly disable back button of a browser while taking online exam?

In online examination once candidate has clicks on start button i dont want to allow him to go back (to previous pages) and he should be in same page if he do any activities by using browser properties.Once he click on the submit button he is coming out of that page.

Here if i clear the cache and press the browser back button the page says as "Document Expired The requested document is not available in Firefox's cache." Therefore i dont want to clear cach insted i need to competly disable back button ie nothing should happen on clicking the back button.

if anybody knows let me know how to achieve this concept......

like image 711
Paramesh Reddy Avatar asked Jan 03 '14 05:01

Paramesh Reddy


People also ask

How do I get rid of the back button in Chrome?

To disable the browser "Back" button for a specific page: Open the "UI" tab of the page description window ( "Description" option in the page popup menu). In the "Options" area, for the option "Browser "Back" button", select "Forbidden".

How do some websites disable the back button?

Script preventing you from going back Some websites add code to their pages that prevent users from using the back button to leave their pages or site. Unfortunately, there is no easy way to fix and get around that type of code.

How do I disable back forward and refresh functionality in browser?

function disableBackButton() { window. history. forward(); } setTimeout("disableBackButton()", 0);


2 Answers

Try this script

<script>
window.location.hash="no-back-button";
window.location.hash="Again-No-back-button";//again because google chrome don't insert first hash into history
window.onhashchange=function(){window.location.hash="no-back-button";}
</script> 

Also refer this link. This link contain demo & Download code

like image 125
Padmanathan J Avatar answered Oct 24 '22 14:10

Padmanathan J


Try with the below code. This code tested with latest Chrome and Firefox browsers.

<script type="text/javascript">
    history.pushState(null, null, location.href);
    history.back();
    history.forward();
    window.onpopstate = function () { history.go(1); };
</script>
like image 38
Franklin Innocent F Avatar answered Oct 24 '22 13:10

Franklin Innocent F