Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

disabling backspace for the browser

 
urvi patel
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i an application for taking online examination using jsp and orcle,
the person taking the exam gets questions on different pages.After he has answered one question he cannot come back to the previous question.for that the backspace key needs to be disabled.please help me in getting this thing done.
send me the detailed code...
Thanking you....
urvi
 
Chris Baron
Ranch Hand
Posts: 1061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
location.replace()disables browser-back-button, back in contextmenu and backspace as it overwrites the actual entry in the browsers history. Maybe there's a better way ( e.g. waiting 4 Eric Pascarello ), but here is an example that might help you:

cb
 
Devesh H Rao
Ranch Hand
Posts: 687
Hibernate jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
i use this function hope it helps..
document.onkeydown = mykeyhandler;
function mykeyhandler() {
if (window.event && window.event.keyCode == 8) {
// try to cancel the backspace
window.event.cancelBubble = true;
window.event.returnValue = false;
return false;
}
}
 
Gary McGath
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even if you disable the backspace key, that won't solve your problem. There are too many ways to navigate back to a previous page, and in many browsers hitting backspace isn't even one of them. (The truth is, I didn't know there were any browsers in which backspace does that!)
There are several ways in JSP to prevent earlier information from being shown again. One is to have a session variable that controls which question is being presented, and is incremented each time an answer is submitted. Since all the questions are being presented in the same page, and the URL doesn't change, browser navigation functions won't allow going back to an earlier question.
This won't stop them from starting all over with a clean slate. You'll need to keep some kind of persistent record on each person to monitor that.
 
urvi patel
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks For ur. answeres...
urvi
 
A day job? In an office? My worst nightmare! Comfort me tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!