Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 23rd, 2009, 12:13 PM
Authorized User
Points: 292, Level: 5
Points: 292, Level: 5 Points: 292, Level: 5 Points: 292, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2005
Location: , , .
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!

Reply With Quote
  #2 (permalink)  
Old April 23rd, 2009, 01:51 PM
Authorized User
Points: 292, Level: 5
Points: 292, Level: 5 Points: 292, Level: 5 Points: 292, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2005
Location: , , .
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!
Reply With Quote
  #3 (permalink)  
Old April 23rd, 2009, 06:51 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
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
Reply With Quote
  #4 (permalink)  
Old April 23rd, 2009, 07:46 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
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.
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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 10:11 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.