If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Disable Back Button

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-11-04, 06:13
Saravanan.R Saravanan.R is offline
Registered User
 
Join Date: Feb 2004
Location: India
Posts: 135
Disable Back Button

hi all,

how to disable browser's back button...

for example:

i am in first.asp and then i am going to second.asp by pressing submit button.here, u can see browser's back button will be enabled.....

but, what i need is ,
in second.asp page ....i should not see back button will enable....

so plz give code,how to disable browser's back button.....
Reply With Quote
  #2 (permalink)  
Old 03-11-04, 09:17
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
can't do it.... full stop. end of story, thanks for playing
Reply With Quote
  #3 (permalink)  
Old 03-11-04, 09:56
Saravanan.R Saravanan.R is offline
Registered User
 
Join Date: Feb 2004
Location: India
Posts: 135
No. its possible man.
Reply With Quote
  #4 (permalink)  
Old 03-11-04, 22:31
gyuan gyuan is offline
Registered User
 
Join Date: Dec 2003
Posts: 454
Close your browser of your first page and open the new one for your second page.
Reply With Quote
  #5 (permalink)  
Old 03-12-04, 01:29
Bullschmidt Bullschmidt is offline
Guru
 
Join Date: Jun 2003
Location: USA
Posts: 1,032
A1ien51's disable the Back Button
http://www10.brinkster.com/A1ien51/S...BackButton.htm
What is going to happen, is when the page loads, it will send the surfer to the last page in their history.
Now if a person tries to go back to it, then it will send them directly back to the page they pushed the back button on!
Add this code to the header of your page:
<script>
history.forward();
</script>

JPS: Thus need to put the code on the page you don't want the user to be able to go back to.
And here is my version of it:
<script type="text/javascript"> <!--
// Disable browser's Back button on another pg being able to go back to this pg.
history.forward();
//-->
</script>
__________________
J. Paul Schmidt, Freelance Web and Database Developer
www.Bullschmidt.com
Access Database Sample, Web Database Sample, ASP Design Tips
Reply With Quote
  #6 (permalink)  
Old 03-12-04, 01:54
Saravanan.R Saravanan.R is offline
Registered User
 
Join Date: Feb 2004
Location: India
Posts: 135
thanx schmidt.

it works
Reply With Quote
  #7 (permalink)  
Old 03-12-04, 15:56
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
it'll only work if they press the back button once. Pressing it multiple times will return them eventually to a page without this code. So techincally you have disabled it at all...
Reply With Quote
  #8 (permalink)  
Old 03-12-04, 16:47
Bullschmidt Bullschmidt is offline
Guru
 
Join Date: Jun 2003
Location: USA
Posts: 1,032
<<
it'll only work if they press the back button once. Pressing it multiple times will return them eventually to a page without this code. So techincally you have disabled it at all...
>>

I just tested clicking on the browser's Back button multiple times on some of my pages that actually use this feature and the back button WAS effectively disabled.
__________________
J. Paul Schmidt, Freelance Web and Database Developer
www.Bullschmidt.com
Access Database Sample, Web Database Sample, ASP Design Tips
Reply With Quote
  #9 (permalink)  
Old 03-14-04, 15:33
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
Well I have tried it here and can easily leap back pages... of course it could be due to a slow connection speed due to dial up....

I'm not trying to knock the solution, I think it is the best you will get. I just want the guy to be aware that in essence it's not completely disabled...

Personally I can't understand why you would want to do something like that in the first place.

Last edited by rokslide; 03-14-04 at 15:36.
Reply With Quote
  #10 (permalink)  
Old 03-15-04, 03:21
Bullschmidt Bullschmidt is offline
Guru
 
Join Date: Jun 2003
Location: USA
Posts: 1,032
<<
Personally I can't understand why you would want to do something like that in the first place.
>>

Well I've used it for a confirmation page where a user just registered something and I don't want the user to just use the browser's back button to go back and change the last page (or pages before that) and in effect submit another registration...
__________________
J. Paul Schmidt, Freelance Web and Database Developer
www.Bullschmidt.com
Access Database Sample, Web Database Sample, ASP Design Tips
Reply With Quote
  #11 (permalink)  
Old 03-15-04, 15:12
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
In that case I'd disable the button that submits the the registration, not the back button.
Reply With Quote
  #12 (permalink)  
Old 03-15-04, 16:58
gyuan gyuan is offline
Registered User
 
Join Date: Dec 2003
Posts: 454
If the user types and hits the url on the browser the registration form will be submitted again. You can use session variable to prevent the user from double submit of the form.
Reply With Quote
  #13 (permalink)  
Old 03-15-04, 17:08
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
Yup, depending on how the form can be submitted there are various ways to prevent the multiple submitting.... disabling the back button IMO is a cop out for doing the job properly... not trying to be rude or anything...
Reply With Quote
  #14 (permalink)  
Old 03-15-04, 18:35
Bullschmidt Bullschmidt is offline
Guru
 
Join Date: Jun 2003
Location: USA
Posts: 1,032
<<
If the user types and hits the url on the browser the registration form will be submitted again. You can use session variable to prevent the user from double submit of the form.
>>

Yes, session variables can and are being checked everytime a page is opened to make sure someone can't get in (again) if you don't want him too.

But the browser's back button is sort of a "loophole" to still allow the user back to a page you don't want him on anymore. For example even after a session times out a user can still hit the browser's back button and get onto a session variable protected page.

The code above keeps this from happening and works very well for this admittedly limited use purpose.

In other words I don't use this code very often but there are some times when it does come in handy.
__________________
J. Paul Schmidt, Freelance Web and Database Developer
www.Bullschmidt.com
Access Database Sample, Web Database Sample, ASP Design Tips
Reply With Quote
  #15 (permalink)  
Old 03-15-04, 18:39
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
Yeah, I can see that it would be kinda handy, but I wouldn't use it as a "this will stop them submitting multiple requests" solution.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On