Click here to Skip to main content
15,940,550 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hai....
In my online test website I am displaying all the questions in the same page one after another using the next button. I need to prevent the use of the back button and refresh button. How can it be possible on the same page?
Thanks...
Posted

Apply this script, it worked fine for me in all browsers

XML
<script type="text/javascript">
function noBack(){window.history.forward();}
noBack();
window.onload=noBack;
window.onpageshow=function(evt){if(evt.persisted)noBack();}
window.onunload=function(){void(0);}
</script>
 
Share this answer
 
Comments
Neha Thanka 5-Sep-11 4:38am    
This solution helped me a lot....
Thanks....
Anuja Pawar Indore 5-Sep-11 8:02am    
Yup............ Enjoy programming :)
To prevents user to visit their last visited page disable browser back button

XML
<script type="text/javascript">
window.history.forward(1);
//On clicking browser back button  allows user to stay on same page.


To Disable refresh button of browser
please refer

http://forums.asp.net/t/1274340.aspx


may help
 
Share this answer
 
Hello friend see this

Browser back button issue after logout[^]

How to block user to go back..?[^]

this will help you...
 
Share this answer
 
Hi,
This link will help you.Disable Back button
Thanks
Kannan
www.steadfastglobal.com
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900