Possible Duplicate:
Prevent Use of the Back Button (in IE)
Disabling Back button on the browser
How to disable Back button in IE and firefox?
Penalty of times, i did not think it appropriate to post this question because it has been already asked lot of times, but this time I am posting being ready for consequences, because I have no other option. I will answer any comments, I can also show my try(in which you would be interested) at any link given below.
I have a loginpage and a page1. I need to handle or not work browser back button on loginpage. It is possible as I have done it for FF and Chrome but unable to do for IE. My working code for FF is following.
window.onload = function ()
{
if (typeof history.pushState === "function")
{
history.pushState("jibberish", null, null);
window.onpopstate = function ()
{
history.pushState('newjibberish', null, null);
// alert('back button pressed');
// This works in Chrome and FireFox but not in IE
};
}
}
I need to have some code (working on all browsers) in my loginpage so that : Desired Output : pressing back button on login page would not take user back to page1 (just like facebook login page). I do not want to disable back button, just to handle its click on loginpage.
Edit From Comments. Please give answer what to do, i have read "Not to do this" but not what to do. Following Code works on pageload ever time except when this page (page1) is loaded through a back button click on loginpage
if (Session["role"] == null)
Response.Redirect("login.aspx");
I have tried to follow a few questions on same issue, but have been unable to get what I need. I will prefer not using window.location.hash just but ready if there is no other solution
Code Project - Browser back button issue after logout
BlogSpot - Detect back Button of Browser
SO - Disable browser back Button
SO - Disabling Back button on the browser
SO - On window.location.hash - change?
Following are few plugins. I tried to follow, but don't know if they are made for what I need and if they are I have been unable to use any of them correctly