Solved

How to disable Browser back button?

Posted on 2001-07-21
17
217 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
  • 4
  • 4
  • 3
  • +5
17 Comments
 
LVL 15

Expert Comment

by:a.marsh
Comment Utility
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
Comment Utility
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
Comment Utility

 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
 
LVL 33

Expert Comment

by:hongjun
Comment Utility
0
 
LVL 15

Expert Comment

by:a.marsh
Comment Utility
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
Comment Utility

 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
Comment Utility
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
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 15

Expert Comment

by:a.marsh
Comment Utility
falkon, please reject the proposed answer.

Ant
0
 
LVL 33

Expert Comment

by:hongjun
Comment Utility
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
Comment Utility
>Why there's no justice in EE?

There is now.
0
 
LVL 3

Expert Comment

by:modder
Comment Utility
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
Comment Utility
Great job modder. Thank you.

:o)

Ant
0
 
LVL 33

Expert Comment

by:hongjun
Comment Utility
Great.

hongjun
0
 

Author Comment

by:falkon
Comment Utility
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
Comment Utility
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
Comment Utility
Try this:

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

Pablo.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article discusses how to create an extensible mechanism for linked drop downs.
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now