Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to stay in the current page..even when the user clicks back..it should stay in the current page instead of going back to the old screen??
Posted
Comments
Uday P.Singh 16-Mar-12 8:49am    
why you want to do that?

Have a look at an article I wrote recently

Web Development - Disabling the back button[^]

What you're trying to do is wrong. You shouldn't attempt to disable the back button using script, that will never work reliably and will just annoy your users
 
Share this answer
 
Comments
Uday P.Singh 16-Mar-12 9:45am    
Agree 5!
Try this code it will disable the back button not only in firefox but also in MSIE, Safari and Opera.
HTML
<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>

Or else force the cache to expire for this to work. Place the following code on your page code behind.
C#
Page.Response.Cache.SetCacheability(HttpCacheability.NoCache)
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900