BACK

How can I prevent someone from using the BACK button to go back to the previous page they were on?  I have a quiz on my site and want to prevent someone who gets the answer wrong from going BACK and taking another guess at the same question.  Is there something I can add to a meta tag to prevent them from being able to use the back button on their web browser?
gcasselAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

JonzaCommented:
No, you cant prevent users from using the BACK -button...
0
JonzaCommented:
But for your purpose it would be possible to store allready answer to a session or cookie variable and allways when user answers a question some script would check if that variable allready exists (user is cheating).

Can you use PHP on your server?
0
kasandraCommented:
The other option is to launch the quiz in a new window, and turn off the toolbars. Then they can't press the back button, because there won't be one visible for the window.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

JonzaCommented:
kasandra that doesn't work perfectly.
yea, you can turn off the toolbars but not for all browsers. some browser just don't allow it. and you still can use keyboard shortcuts to go back.
0
kasandraCommented:
But how many people know the keyboard shortcuts?

It is a very straightforward approach to try, without requiring any PHP etc, just javascript to launch the window.
0
JonzaCommented:
the people that usually knows that you could cheat bu going back knows the KB-shortcuts.. hey it isn't that difficult just press backspace...

still recommend the cookie thing =)
0
kasandraCommented:
Just offering an alternative to try...

Since the answer to "can I disable the back button?" is no, as Jonza correctly pointed out, we're now offering "workarounds" rather than solutions. There is no solution.

One particular workaround is not necessarily going to be the one true answer, so all we can do is offer different suggestions to see if one in particular (or a combination) appeals to gcassel.
0
COBOLdinosaurCommented:
You can place this code:

<script language=JavaScript>
<!--
   history.forward()
//-->
</script>

at the top of all your pages that you do not want them to go back to.
history.forward() will push the browser to the next page in the
history. So, if it's on every page, it will always bring them all
the way back to the page they were on.  It won't bounce them when they
come to a page initially because there is no next page.

Cd&
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gcasselAuthor Commented:
I want to thank kassandra and jonza for their comments.  I actually did code the pages with a session variable to check for users trying to go back and redo the same question.  I discovered that without this check a user could easily run up their score by continually hitting the back button and doing the same question over and over again.  The seesion variable seems to work but I have had some users who have remarkably been able to score very high within a short period of time.  I therefore was looking for another method to make sure they could not go back and work around my code.  The one suggested by COBOLdinosaur fills the bill.  Thanks.  It is nice to see that old reptiles can learn new tricks.
0
COBOLdinosaurCommented:
Actually it is an old trick.  Not useful for most situations, because it can really irritate users when you mess with navigation.  However this is the sort of application where a little dirty trick prevents the cheat; so the only complaint they could make would be that they can't cheat anymore. ;^)

Glad we could help.  Thanks for the A. :^)

Cd&
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.