disable back button browser

Posted by Chilverupavan under Regular Expressions on 4/30/2010 | Views : 22412 | Status : [Member] | Replies : 4
hai frnds,,

i need to disable the firefox browser back button when user click on logout button..................




Responses

Posted by: Vuyiswamb on: 4/30/2010 [Member] [MVP] [Administrator] NotApplicable
Posted by: Naveenmanam on: 5/2/2010 [Member] Starter

Up
0
Down
you understand the issues. How can you bounce the user forward to the latest page? It's not all that hard to do with JavaScript. There are catches, but I've already sorted them out for you.
On the surface, the job is simple. All we have to do is call history.forward() and we're done! Unfortunately, there's a big catch: exactly how and when are we going to call it?

Calling history.forward() from the onLoad handler of the body element sounds like a no-brainer, doesn't it! Unfortunately, many web browsers do not call onLoad when the user backs up to a page. Examples include Safari, Opera, and Firefox (in some situations and not others).

Working Around the onLoad Problem
So what's the solution? Well, all of the browsers that don't call onLoad when you back up to a page do remember the state of any JavaScript timers (setTimeout calls) that were made on that page. Those calls are paused, but the moment you back up to the page, the clock starts ticking again.
But how does setTimeout help us? It's very simple. The first time the page loads, onLoad is always called. And we use that to set up our timer... which tries to move forward to the next page in the browser history once every quarter-second. If it can't, we're already on the newest page - not a problem!

So what happens when the user backs up? If they are


NaveenKumar

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

Posted by: Er.deepakdalal on: 5/2/2010 [Member] Starter

Up
0
Down
Hi Chilverupavan

Try this code it will disable the back button not only in firefox but also in MSIE, Safari and Opera.

<html>
<head>
<script type="text/javascript">
window.history.forward();
function noBack(){ window.history.forward(); }
</script>
</head>
<body onload="noBack();" onpageshow="if (event.persisted) noBack();" onunload="">
...
</body>
</html>

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

Posted by: Muhilan on: 5/2/2010 [Member] Starter

Up
0
Down
try server side code

Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetAllowResponseInBrowserHistory(false);


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

Login to post response