How do i disable browser back button using C# or JavaScript?

Posted by Vijaybhaskarch under C# on 1/3/2008 | Views : 15230 | Status : [Member] | Replies : 8
Once user clicks on Logout he should not be able to go back (by clicking on browsers back button). Remember cahing is there. we should not remove chahing. he can be able to click on browsers back button or he can view previous page by click on browsers back button only when user is in login. Once logout he should not able to view previous page.




Responses

Posted by: Lakn2 on: 5/16/2011 [Member] Starter | Points: 25

Up
0
Down
<script language="text/javascript">
function back()
{
window.history.forward(1)
}
</script>
in onload call back function

Thanks&Regards
LakshmiNarayana Nalluri.

Vijaybhaskarch, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nithadeepak on: 5/16/2011 [Member] Bronze | Points: 25

Up
0
Down
Refer the reply of DotNetSeeker in the below link:
http://forums.asp.net/t/1161997.aspx/2/10
Thanks,

Nitha Deepak

Vijaybhaskarch, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vforvijay on: 5/16/2011 [Member] Starter | Points: 25

Up
0
Down
hi..you try this link to avoid user to use Back Button..
http://vbdotnetaddict.blogspot.com/2011/02/how-to-disable-back-button-in-aspnet.html

Vijaybhaskarch, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Susanthampy on: 5/19/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
<script language="JavaScript">
javascript:window.history.forward(1);
</script>


Regards,
Susan

Vijaybhaskarch, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hebsiboy on: 5/20/2012 [Member] Starter | Points: 25

Up
0
Down
To write this inside the head tage

<script type = "text/javascript" >
function preventBack(){window.history.forward();}
setTimeout("preventBack()", 10);
window.onunload=function(){null};
</script>



 Download source file

Vijaybhaskarch, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Deysomnath on: 1/8/2008 [Member] Starter

Up
0
Down
Hi,
you can not disable browser back button however you can restrict user not to visit last page using javascript


Eg:


<html>
<head>
<script>
javascript:window.history.forward(1);

</script>

</head>
<body >
hai <a href="abc.html">click here to go to 2nd page</a>
</body>
</html>



Vijaybhaskarch, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Chitrad on: 10/3/2008 [Member] Starter

Up
0
Down
after logout, it redirects to login screen. In login screen, we can use
window.history.forward(1); so that it will not go previous page.

Vijaybhaskarch, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Tridev_2005 on: 10/12/2009 [Member] Starter

Up
0
Down
Put this in the header of every page :

<script type="text/javascript">

function noBack(){window.history.forward()}
noBack();
window.onload=noBack;
window.onpageshow=function(evt){if(evt.persisted)noBack()}
window.onunload=function(){void(0)}
</script>


more info

http://www.dotnetspider.com/resources/6133-How-disable-back-button-e-browser-after-lo.aspx

Vijaybhaskarch, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response