Solved

Back button

Posted on 2000-05-05
11
197 Views
Last Modified: 2013-12-25
How can I prevent a user from using the back button?

I have a registration page, when registered I don't won't them pressing the back button and doing it again!

Any ideas?
0
Comment
Question by:mshire
11 Comments
 
LVL 2

Expert Comment

by:Jagar
ID: 2781928
You can't
0
 
LVL 3

Expert Comment

by:bark10
ID: 2781990
Jagar is right, there is no way you can STOP them from using the back button.  

The best you can do warn them about what they are doing.  Maybe using onbeforeunload() you could give them a choice as to if they really want to leave.

Or, make the registration page a seperate pop-up window with no buttons or bars at all except for the submit button that closes the window on submit.
0
 
LVL 2

Expert Comment

by:READER
ID: 2783206
Open the registration page with the back button disabled.

Here is how to do:

(1) Put following Javascript in your header section
 
<script language="JavaScript">
<!--
 function openNewWindow(url){
  window.open(url,"NewWindow","width=625,height=320,status,menubar,
scrollbars, toolbar,resizable,directories");
  }
// --></script>


(2)  Put following around your HREF tags for registration page

                 javascript:openNewWindow(' URL ')


                   Here's an example.........

                 href="javascript:openNewWindow('http://xxxxxxxx.com')"

   
0
 
LVL 11

Expert Comment

by:mouatts
ID: 2784695
As has been said before you can't stop them pressing the button, except by opening a new window without any buttons on it.

However you can negate them pressing a back button. Assuming that they are on Page A move to Page C and you don't want them to go back to A.

What you actually do is when they leave Page A they go to page B which is just a redirection to page C.

Now if they press back they will go to B which pushes them back to C immediately.

further details are available at http://www.bedrockcomputers.demoin.co.uk/faq.html

HTH
Steve
0
 

Author Comment

by:mshire
ID: 2785388
Yeah that sounds like a good idea... if they press the back button after registering, it would load the previous page, find out they are already registered and redirect them. But how do I get the page to refresh even after pressing the back button (the <meta HTTP-EQUIV="EXPIRES" content="0"> doesn't seem to work always)

Thanks,

Mike

PS mouatts - that link didn't seem to work...
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 2

Expert Comment

by:READER
ID: 2786069
To get a page to refresh every time include the following meta tag in your headers.

<meta http-equiv="Pragma" content="no-cache;>
0
 
LVL 11

Expert Comment

by:mouatts
ID: 2788066
Reader is correct that you should use pragma nocache to refresh a page. But to do a redirection you should use the Location Message (from HTTP) or refresh with a 0 type from a META tag. ie

<META HTTP-EQUIV="Refresh" CONTENT="0; URL=http://mydomain.com/myfile.html">

But if this redirection is out of a CGI then you should use the following

printf("Location: www.mydomain.com/myfile.html \n\n");

(thats suitable for C and Perl and for ASP

response.redirect("myfile.html")

Sorry about the link it should be http://www.bedrockcomputers.demon.co.uk/faq.html

0
 
LVL 11

Expert Comment

by:mouatts
ID: 2815976
Did that solve your problem.

Steve
0
 

Accepted Solution

by:
Ironwolf earned 100 total points
ID: 2892837
If you put this code on the top of your registration page:

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

then every time they go back to this page, using the back button, a right click, alt+backArrow, or any other method, it will automatically push them forward to the page they came from.

You can put this on every page of your web if you want them to only be able to navigate your page through the links.

This method is very effective when you have a data-driven web where the data is constantly updated and you want to make sure it is refreshed upon each viewing.

-IW
0
 
LVL 11

Expert Comment

by:mouatts
ID: 2918190
Ironwolf: Did you really have to post this as an answer! BTW turn off javascript and it fails.
0
 

Expert Comment

by:lankford
ID: 103422
Not that anyone will care, but if you code the page as an hta instead of regular html, back will simply be disabled as a feature in the user's browser.

This, of course, brings lots of other issues to the table.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Accessibility and Usability are two concepts that seem to be closely related.  But, too many people seem to have a distorted perception of them. During last five years, those two words have come to the day-to-day work of almost every web develope…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now