Solved

How to disable Browser back button?

Posted on 2001-07-21
17
224 Views
Last Modified: 2012-06-27
Hi friends,
Is there a way to disable the Back button in the Browser. Give details.
0
Comment
Question by:falkon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 3
  • +5
17 Comments
 
LVL 15

Expert Comment

by:a.marsh
ID: 6304613
Basically you can't - at least not 100% guaranteed.

Check out:

http://developer.irt.org/script/311.htm

:o)

Ant
0
 

Expert Comment

by:LorangerG
ID: 6304803
a. marsh is correct but you can try the following:

1) You can use the location replace method when changing the location. This replaces the current history location with the new location. However older browsers do not support this method, which is why it is required to test for the images object:

<script language="JavaScript"><!--
if (document.images)
    location.replace('http://www.somewhere.com/apage.html');
else
    location.href = 'apage.html';
//--></script>

 

Note: in Opera replace() will work, but only with absolute URL's.

2) You can load the new location into another window, and then close the old window:

In the first page:

<script langauge="JavaScript"><!--
function newWindow(fileName,windowName) { msgWindow=window.open(fileName,windowName); }
//--></script>

<a href="javascript:newWindow('1.html','window1')">Open Window</a>

 

In the next window:

<script language="JavaScript"><!--
function newWindow(fileName,windowName) { msgWindow=window.open(fileName,windowName); }
function replaceURL(fileName) { newWindow(fileName,'window2'); self.close(); }
//--></script>

<a href="javascript:replaceURL('2.html')">change location</a>

 

3) You can open a window without a toolbar:

<script language="JavaScript"><!--
msgWindow=window.open('apage.html','windowName','toolbar=no');
//--></script>

 

However, this does not totally stop the user from being able to go back to the previous page.

4) You can add code to the previous page to force the browser to go forwards again:

<script language="JavaScript"><!--
javascript:window.history.forward(1);
//--></script>

 
0
 

Expert Comment

by:LorangerG
ID: 6304809

 Wait a minute. Sorry a. marsh, I did not see you URL. Falcon, the methods I commented on are in the URL a. marsh recommended. Sorry marsh, I wasn't trying to scope your points.
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 33

Expert Comment

by:hongjun
ID: 6304858
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6304863
Apology accepted. :o)

falkon, please note that if you find the comments that LorangerG gave useful, then you should accept MY comment as the answer as the URL says almost EXACTLY the same thing!

Did you copy and paste the text LorangerG?

:o)

Ant
0
 

Expert Comment

by:WebDevOne
ID: 6304869

 It DOES say the exact same thing. Yes, it's pasted from the source.
0
 
LVL 1

Accepted Solution

by:
faraj earned 200 total points
ID: 6305996
The location object's replace() method overwrites the current history entry with the specified URL. It removes the current history entry before the next URL is loaded. Removing the item from the history list also prevents users from seeing the page again by clicking on the Back button later.
This technique is very useful for online games and multi-page forms, where you want prevent the user from returning to the previous page. Furthermore, the location.replace() method is supported by all browsers except Navigator 2.0x. The following example shows how to use this method in a link:


<A HREF="javascript:location.replace('nextpage.html')">Advance</A>
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6306182
faraj,

You are here long enough to know EE policy. The policy here is to post everyhing in comments. Questionner will then have the option to accept a comment as an answer. Posting as a proposed answer will lock the question and thus restrict the exposure to more experts. We know you are new here and thus is forgiven. With the current version of EE, you do not have the option to convert your answer to a comment but this can be done by the questioner himself. I advise the questionner to reject his answer so that this question will be released to more experts. You can however accept his comment again if you find it is really helpful.


Anyway, faraj's comment is being covered by links posted by many of the above comments including mine.

Thanks
hongjun
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6306306
falkon, please reject the proposed answer.

Ant
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6311265
Why there's no justice in EE? I personally feels that faraj's answer is a repeated one. Bad choice falkon.

hongjun
0
 
LVL 3

Expert Comment

by:modder
ID: 6317703
>Why there's no justice in EE?

There is now.
0
 
LVL 3

Expert Comment

by:modder
ID: 6317720
OK. Here is what I've done:

1) Increased points from 100 to 200. falkon can have the extra 100 points back if (s)he has the decency to return to this question and explain what is going on.

2) Reduced faraj's expert points to ensure that faraj has not benefited from this question.

3) Posted a new question, http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=javascript&qid=20156939, for a.marsh, to give you the points you deserved.

modder
Community Support
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6317882
Great job modder. Thank you.

:o)

Ant
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6321667
Great.

hongjun
0
 

Author Comment

by:falkon
ID: 6329413
Hai guys,
I am sorry. In a hurry i did that and i didnt have much time to go thro' all those comments when accepted faraj's answer.
0
 
LVL 3

Expert Comment

by:modder
ID: 6535309
Hai falkon,

I am sorry. In a hurry. I don't have much time to deal with users who cannot be bothered to participate in Experts-Exchange in a constructive manner so I have closed your account.

Everybody else, sorry it took me a while to finalize this.
0
 

Expert Comment

by:Evolutionmarketplace
ID: 10268862
Try this:

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

Pablo.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

733 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