Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 23rd, 2009, 12:13 PM
Authorized User
 
Join Date: Dec 2005
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Question Blocking the back button

I've read that you can't disable the "back" button functionality in a browser (especially IE). Is there any way around this? I don't want my users to click back on some pages because it leads to double entries in my DB...along with a lot of other nasty side effects. Any and all suggestions are very appreciated!

 
Old April 23rd, 2009, 01:51 PM
Authorized User
 
Join Date: Dec 2005
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Lightbulb Found a workaround

After researching, I found you can't exactly disable the back button. But I found a neat script that just sends the browser back forward again.

< script >
history.forward(1)
< / script >

(without the spaces in the script tags) Is working like a charm.

Thanks for being a great bunch of people!
 
Old April 23rd, 2009, 06:51 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

"......because it leads to double entries in my DB"

Constructivley, my 2 cents worth:

As im sure you know they can get back other ways than using the back button. Lets face it, users click the back button. Accept it and work on a better deisgn/workflow around your code that inserts to the DB. Posting forms in a way that that can not insert multiple entries is fairly simple stuff.

Commonly you can get this if you post to the same page the form is on, or you post to a page the user can see. In this case I sometimes write code that checks if the insert has taken place. I find the posting to a transaction page which the user does not see works well.

Also your way relies on JS. You do realize some, IMO wierdos have it disabled...
__________________
Wind is your friend
Matt
 
Old April 23rd, 2009, 07:46 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

And to pick another example, if you use MSIE 6 and before and click on NEW menu and then on WINDOW menu item, a *clone* of the page you are one is created. And so if the user submits from both those windows you will have similar duplicated data problems.

In short, Mat is oh so right. Don't rely on clever browser-side tricks to avoid double posting. Let the server help you do the right thing.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Back Button j_rumpa Javascript How-To 8 July 4th, 2007 08:29 AM
Back Button in IE kishor_ys BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 September 4th, 2006 09:05 AM
Back Button abdul_owiusa General .NET 1 November 11th, 2005 09:58 AM
Back Button DARSIN General .NET 0 March 1st, 2005 08:00 AM
history.back or hitting the back button won't work lian_a Classic ASP Basics 4 July 29th, 2004 12:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.