Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: IE7 C# ASP.NET Javascript
dear friends,
 

I have Question For U..
 
how to disable Back-Button in Browser while running applications using java script. and Does Not Page Refreshing or Reload.
While pressing Back Button.
????
 
By Mohan
Posted 3-Nov-11 1:51am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

We can disable the back navigation by adding following code in the webpage. Now the catch here is that you have to add this code in all the pages where you want to avoid user to get back from previous page. For example user follows the navigation page1 -> page2. And you want to stop user from page2 to go back to page1. In this case all following code in page1.
 

<script type="text/javascript">
    window.history.forward();
    function noBack() { window.history.forward(); }
</SCRIPT>
</HEAD>
<BODY onload="noBack();"
    onpageshow="if (event.persisted) noBack();" onunload=""></script>
  Permalink  
Comments
mohankumar345 at 3-Nov-11 6:59am
   
your answer is correct but page is reloaded.
I want without page reload while clicking back button in browser..
 
by mohan
arya1685 at 3-Nov-11 7:34am
   
Try this one
 
<body önUnload="noBack()">
<script>
function noBack()
{
<span class="IL_AD" id="IL_AD1">window</span>.history.forward(1);
}
</script>
 
You can also use the below script, but i have noticed that it wont work in some browsers especially Mozilla v 3.5
view sourceprint?
if(history.length>0)
{
history.go(+1)
}
BobJanova at 3-Nov-11 7:13am
   
This doesn't disable back, it causes the page you go back to to immediately ask to go forward again. The user can probably stop that happening by pressing Escape to cancel the load.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Don't. Instead, make your site back-button (and open-in-new-tab etc, all the things that web users can easily do) tolerant. If you set your cache control headers and session state correctly, it shouldn't matter if users go back, they will either get a cached version (no server hit) if appropriate or a message telling them that the operation is no longer valid if that makes more sense.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Try this
 
<body onunload="javascript:history.go(1)">
 
Or see this
 
http://viralpatel.net/blogs/2009/11/disable-back-button-browser-javascript.html[^]
 
http://www.irt.org/script/311.htm[^]
  Permalink  
v2
Comments
BobJanova at 3-Nov-11 7:49am
   
That doesn't work if the user uses a 'multi-back' dropdown like all modern browsers have (though it will make them not go to the page they thought which will annoy them).
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

dear friends,

 
I have Question For U..

how to disable Back-Button in Browser while running applications using mobile application . and Does Not Page Refreshing or Reload.
While pressing Back Button.
????
  Permalink  
Comments
B Birajdar at 3-Jan-12 8:49am
   
I am not able to understand your term "Back-Button in Browser while running applications using mobile application". Do you want this functionality in a native mobile application or a mobile web application which runs inside a browser?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 240
1 Kamal Rocks 184
2 BillWoodruff 173
3 Sergey Alexandrovich Kryukov 170
4 PIEBALDconsult 160
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,180


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 3 Jan 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100