2

My app is running fine on chrome but in Firefox (v 32.0) , it's creating one problem.

As after log out, if go back by clicking the browser's back button. It should not allow to go back and load the previously visited page.

I have coded well to achieve this and works fine everywhere. It works fine in chrome also. But in case of firefox browser's back button, it's not refreshing/reloading the page and simply shows the previously visited page.

I think If I make it reload the page on back button clicking then it'll be solved.

For this, I tried by the following code on that page:

<input type="hidden" id="refreshed" value="no">
    <script type="text/javascript">
    onload=function(){
      console.log("method called.......");
    var e=document.getElementById("refreshed");
    if(e.value=="no")
     {
       e.value="yes";
      }
    else
      {
       e.value="no";
       location.reload();
      }
    }
    </script>

But it didn't work.

Any suggestion please ?

NawazSE
  • 593
  • 4
  • 9
  • 21

1 Answers1

0

I doubt that your code works, I cannot see how it will ever reach the else because onload happens only once at page load, and reload will call it again on the next page load. To prevent the back button, you can use window.onbeforeunload.

More details here : how to stop browser back button using javascript

Community
  • 1
  • 1
ovi
  • 566
  • 4
  • 17