top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to disable the browser back button in javascript.

+3 votes
382 views
How to disable the browser back button in javascript.
posted Apr 23, 2015 by Kumar Mitrasen

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
 
Best answer

I am discussing how to prevent user from navigate to previous page using back button of the browser or the back option in the context menu.

One cannot disable the browser back button functionality only thing that can be done is prevent them.

Below is the JavaScript snippets that needs to be placed in the head section of the page where you don’t want the user to revisit using the back button

<script type = "text/javascript" >
   function preventBack(){window.history.forward();}
    setTimeout("preventBack()", 0);
    window.onunload=function(){null};
</script>
answer Apr 27, 2015 by Mohammed Hussain
Similar Questions
+1 vote

How can i prevent onclick button from multiple click until it's confirmation from javascript if(confirm ) condition.

Note:-Solutions could be easy but not able to track because i am naive in UI development, please help me out.

Here is button

<input type="button" onclick="return saveValues();" value="<?php echo "values" ?>" class="silver_button_big">

Respective javaScript call

var saveValues = function() {
         // some code                
        if(isModified() == false){
            jError("It is modified.");
            return;
            }        
             if(confirm("Are you sure")){
              $.post(base_url + 'google/update_values', {
               //some code               
            }
    };
...