backDetect

Determining when a user clicks their browser's back button has never been easier with this jQuery plugin. With a quick easy install and a little bit of set up work you'll be firing callback functions on back button declarations in no time.

View the Project on GitHub ianrogren/jquery-backDetect

Using jQuery-backDetect

It's a very simple and straightforward plugin, just download and call on it in the following way. It can be attached onto any DOM element at either document.ready or window.load, but I would recommend attaching this function to the body at window.load in the folllowing fassion:

      
      $(window).load(function(){
        $('body').backDetect(function(){
          alert("Look forward to the future, not the past!");
        });
      });
    

Please note that IE requires the 1x1.png to function corrlectly. All other browsers are good to go.

Click the back button to test.