Click here to Skip to main content
12,077,731 members (47,823 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: Javascript Firefox
how to disable back button on firefox using javascript
Posted 28-Aug-12 2:54am
Edited 28-Aug-12 3:00am
Legor5.9K
v2
Comments
Legor 28-Aug-12 8:00am
   
You really shouldn't do that. It's a bad habit of restricting users like that and they will not approve it.
Arunprasath Natarajan 28-Aug-12 23:59pm
   
He might require for any Exam, Payment related pages i guess. So he does not want his user to perform such action.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Dear Friend,

Identify the Back Keys, key event and disable the same.
Here I have give a sample code to display the F5 key.

document.onkeydown = function(e) {
      // keycode for F5 function
      if (e.keyCode === 116) {
        return false;
      }
      // keycode for backspace
      if (e.keyCode === 8) {
        // try to cancel the backspace
        return false;
      }
    };

If you want to hide the back button from the browser, then you can hide toolbar by calling the child window.
EG:
newwindow=window.open(url,'','toolbar=no,location=no,menubar=no,scrollbars=yes');
  Permalink  
v2
Comments
Legor 28-Aug-12 8:02am
   
Although this may work with the Backspace key i guess the OP wanted to disable the Button in the Browser GUI (the Left-Arrow) for going back one page. Eitherway i wouldn't suggest anyone restricting an user to do that.
Arunprasath Natarajan 28-Aug-12 10:15am
   
Refer the above edited answer.
SharmilaB 16-Mar-13 6:32am
   
this is working in internet explorer,but not in firefox
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

hiii,


<SCRIPT type="text/javascript">
    window.history.forward();
    function disableBack()
{
window.history.forward();
}
</SCRIPT>
</HEAD>
<BODY onload="disableBack();" onpageshow="if(event.persisted) disableBack();">
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

<script>
$(window).unload(function () {
if (document.getElementById("status").value == "1") {

window.location = "Homepage.aspx";
return true;
}
else {

window.location = "LoginPage.aspx";
return true;
}
});
function Login_Click1() {
document.getElementById("status").value = "1";
}
</script>



Take one hidden field like loading status as 0 like below:

<input type="hidden" id="status" value="0" />
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 5

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<title>Untitled Page</title>
</head>
<body onload="changeHashOnLoad(); ">
Try to hit back!
</body>
</html
  Permalink  
Comments
Karthik_J, Coimbatore 29-Aug-12 4:44am
   
continuously click on back button it will redirect to previous page...!(firefox)
Saroj Chaurasia 27-Aug-13 21:00pm
   
Thank you very much!!! it saved my day...
SharmilaB 16-Mar-13 6:37am
   
Thank you.....the above coding is working in html as well firefox!!!!!!!
prashant patil 4987 28-Aug-13 6:03am
   
Welcome... please Vote me up..
prashant patil 4987 28-Aug-13 6:02am
   
welcome Sharmila..
prashant patil 4987 28-Aug-13 6:03am
   
.. please Vote me up.. if u like my answer..

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web04 | 2.8.160212.1 | Last Updated 29 Aug 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100