Pages

Wednesday, February 23, 2011

Disable back using javascript

After login we come to j\home page & after click on back button it should not move to login page
so we use following script to restrict it
when we traverse through webpages history is maintained. Dont forget to call setTimeout method
It works on Firefox , IE & Chrome  also
 <script type = "text/javascript" >
function disableback()
{
window.history.forward();
}
setTimeout("disableback()", 0);
</script>

Call above method on Body unload method on login page so when u move from login to home page after click on home's back button , we will be on same page that is on home page
<body onunload="disableback()">
 now your back button problem will be solved......

No comments:

Post a Comment