JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 22nd, 2003, 01:36 PM
Mojoman's Avatar
Mojoman Mojoman is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Washington, DC
Posts: 39 Mojoman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 34 m 34 sec
Reputation Power: 16
Is there a way to DISABLE the BACK BUTTON?

I have a multiple page regstration process for a site that I am developing. In initial beta-testing, I have found some users (even though they are warned not to) have been using the back button in the middle of registration - thereby wreaking havoc on the registration process!

I was wondering if there is a way to disable the back button?

TIA!
__________________
$mybrain = "mush";
-------------------------------------------
http://www.loftsboston.com
http://www.gregdawsondesign.com

Reply With Quote
  #2  
Old October 22nd, 2003, 04:56 PM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 785 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 17
Use this Javascript method:

replace Method
The replace method replaces the current History entry with the specified URL. After calling the replace method, you cannot navigate back to the previous URL using the browser's Back button.

Syntax: location.replace(URL)
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
  #3  
Old October 22nd, 2003, 09:02 PM
iahmed iahmed is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Location: USA
Posts: 171 iahmed User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 42 m 58 sec
Reputation Power: 16
<script language="JavaScript">
window.history.forward(1);
</script>

Reply With Quote
  #4  
Old October 22nd, 2003, 09:10 PM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 785 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 17
For the method iahmed proposed, you need to put that code at the bottom of each page that you DON'T want the user to be able to go back to or resubmit.

I suggest you use both methods together.

Reply With Quote
  #5  
Old October 22nd, 2003, 10:43 PM
Mojoman's Avatar
Mojoman Mojoman is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Washington, DC
Posts: 39 Mojoman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 34 m 34 sec
Reputation Power: 16
Thanks for the swift reply! I can't seem to get either of these solutions to work.

How do I use the replace method?

Do I wrap it in a <script language="JavaScript"> tag?

Reply With Quote
  #6  
Old October 23rd, 2003, 12:37 AM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 785 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 17
It can be in a <script></script> block, or you can make it easy.
Try this:

<a href="javascript: location.replace('/');">Home Page</a>

Reply With Quote
  #7  
Old October 23rd, 2003, 10:17 PM
pentapenguin pentapenguin is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 51 pentapenguin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 36 m 7 sec
Reputation Power: 17
Hi.

You might want to look at this too for an alternate solution:
http://www.htmlgoodies.com/tutors/nobackbutton.html

Reply With Quote
  #8  
Old March 22nd, 2005, 06:11 AM
Linus sylvén Linus sylvén is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 1 Linus sylvén User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 50 sec
Reputation Power: 0
Quote:
Originally Posted by Mojoman
I have a multiple page regstration process for a site that I am developing. In initial beta-testing, I have found some users (even though they are warned not to) have been using the back button in the middle of registration - thereby wreaking havoc on the registration process!

I was wondering if there is a way to disable the back button?

TIA!

Hey!

This is a little more dynamic method of doing it.
I needed the possibility to switch the back buttons function on and of depending on what the client where doing.

This is tested in Mozilla firefox and IE, the code is from a separate .js file

This will allow you to turn the back buttons function off with the functions ‘blockBackButton()’

And turn it on again with ‘resetBackButton()’

The script uses the get part of the url, but wont permanently change it becoause if the browser get a changed get part of the url, the script will reload the earlier page were the url was unchanged.


var ie = (window.navigator.appName == "Microsoft Internet Explorer") ? true : false;

function setEventByObject(object, event, func){
if (!ie){
object.addEventListener(event, func, false);
} else {
object.attachEvent("on" + event, func);
}
}

setEventByObject(win, "unload", exitme);
var block = "false";
function blockBackButton(){
block = "true";
}
function resetBackButton(){
block = "false";
}
function jumpforward(){
if(window.location.href.indexOf("&jumpforward")!=-1) {
history.forward();
}
}
jumpforward();
function exitme(){
if(block == "true") window.location.href += "&jumpforward";
}
Comments on this post
rpgivpgmr agrees!

Reply With Quote
  #9  
Old April 25th, 2005, 01:06 PM
rpgivpgmr rpgivpgmr is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Location: Virginia, USA
Posts: 3 rpgivpgmr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 48 m 44 sec
Reputation Power: 0
Thumbs up Kudos

Nicely done.
Thank you.

Quote:
Originally Posted by Linus sylvén
Hey!

This is a little more dynamic method of doing it.
I needed the possibility to switch the back buttons function on and of depending on what the client where doing.

This is tested in Mozilla firefox and IE, the code is from a separate .js file

This will allow you to turn the back buttons function off with the functions ‘blockBackButton()’

And turn it on again with ‘resetBackButton()’

The script uses the get part of the url, but wont permanently change it becoause if the browser get a changed get part of the url, the script will reload the earlier page were the url was unchanged.


var ie = (window.navigator.appName == "Microsoft Internet Explorer") ? true : false;

function setEventByObject(object, event, func){
if (!ie){
object.addEventListener(event, func, false);
} else {
object.attachEvent("on" + event, func);
}
}

setEventByObject(win, "unload", exitme);
var block = "false";
function blockBackButton(){
block = "true";
}
function resetBackButton(){
block = "false";
}
function jumpforward(){
if(window.location.href.indexOf("&jumpforward")!=-1) {
history.forward();
}
}
jumpforward();
function exitme(){
if(block == "true") window.location.href += "&jumpforward";
}

Reply With Quote
  #10  
Old July 19th, 2006, 10:51 AM
sachinpawar1234 sachinpawar1234 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Posts: 1 sachinpawar1234 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 7 sec
Reputation Power: 0
About 'win' parameter

hi,
i gone through this code and tried it but i am getting one error that 'win' is undefined
so plz tell me what is that win
bye





Quote:
Originally Posted by Linus sylvén
Hey!

This is a little more dynamic method of doing it.
I needed the possibility to switch the back buttons function on and of depending on what the client where doing.

This is tested in Mozilla firefox and IE, the code is from a separate .js file

This will allow you to turn the back buttons function off with the functions ‘blockBackButton()’

And turn it on again with ‘resetBackButton()’

The script uses the get part of the url, but wont permanently change it becoause if the browser get a changed get part of the url, the script will reload the earlier page were the url was unchanged.


var ie = (window.navigator.appName == "Microsoft Internet Explorer") ? true : false;

function setEventByObject(object, event, func){
if (!ie){
object.addEventListener(event, func, false);
} else {
object.attachEvent("on" + event, func);
}
}

setEventByObject(win, "unload", exitme);
var block = "false";
function blockBackButton(){
block = "true";
}
function resetBackButton(){
block = "false";
}
function jumpforward(){
if(window.location.href.indexOf("&jumpforward")!=-1) {
history.forward();
}
}
jumpforward();
function exitme(){
if(block == "true") window.location.href += "&jumpforward";
}

Reply With Quote
  #11  
Old July 21st, 2006, 05:42 AM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Click here for more information
 
Join Date: Aug 2004
Location: Sector ZZ9 Plural Z Alpha
Posts: 1,029 Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6
Time spent in forums: 1 Week 12 h 55 m 59 sec
Reputation Power: 16
Send a message via ICQ to Itsacon
First of all, this thread is over a year old, very slim chance you'll get a reply from that poster, seeing he hasn't posted much since then.

Second, whatever way you try to do this (disabling the back button), be ready for the fact it won't work on every browser. Every good browser has ways to disable javascript, and/or settings that determine how much power javascript has.

Do no try to limit a users power over his own computer. If I want to go back, for whatever reason, it's my good damn right. If doing that breaks your site, you should write better code, that checks for stuff like that.
__________________
This is my code. Is it not nifty?

"The biggest problem encountered while trying to design a system that was completely foolproof, was, that people tended to underestimate the ingenuity of complete fools."
---Douglas Adams


Join the Itsacon fanclub!    
Zero Tolerance: Spammers banned so far: 592

Reply With Quote
  #12  
Old August 3rd, 2006, 05:32 AM
John Staub John Staub is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2006
Posts: 1 John Staub User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 12 sec
Reputation Power: 0
Block the Back Button

Quote:
Originally Posted by sachinpawar1234
hi,
i gone through this code and tried it but i am getting one error that 'win' is undefined
so plz tell me what is that win
bye


Hi,

here is a way to get it to work and also let people use the back button after a warning. It also fixes problems with the querystring variables.

<script>
var ie = (window.navigator.appName == "Microsoft Internet Explorer") ? true : false;
window.name = 'test';

function setEventByObject(object, event, func){
if (!ie){
object.addEventListener(event, func, false);
} else {
object.attachEvent("on" + event, func);
}
}
setEventByObject(window, "unload", exitme);


function jumpforward(){
if(window.location.href.indexOf("jumpforward")!=-1) {
history.forward();
}

}

// Block Back Button for this page
var block = "true";





function exitme(){
if(block == "true") {
if(window.location.href.indexOf("?")==-1) {
window.location.href += "?jumpforward";
} else if (window.location.href.indexOf("jumpforward")==-1){
window.location.href += "&jumpforward";

}
alert(Please, please don't use the Back button')
jumpforward();
}

}

</script>

Reply With Quote
  #13  
Old August 3rd, 2006, 01:38 PM
colton22's Avatar
colton22 colton22 is offline
\ ^_^ / - *Local Friend*
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Location: near chicago, Illinois
Posts: 469 colton22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 36 m 37 sec
Reputation Power: 13
Send a message via AIM to colton22 Send a message via MSN to colton22 Send a message via Yahoo to colton22
i agree with Itsacon, you should be able to use the back button

for another reason you could
<script>function ul() {do something to stop you site from being screwed}</script>
<body onunload="ul()">

colton22

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Is there a way to DISABLE the BACK BUTTON?


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap