Determining when a user clicks their browser's back button has never been easier with this jQuery plugin. With a quick easy install and minimal set up work you'll be firing callback functions on back button declarations in no time.
View a demo of it here.
Disclaimer: This plugin was originally developed for an edge case where I did not have access to the all of the history state functions and I needed a way to set localStorage variable when the back button was clicked. This plugin works great for very simple back detection, but if you need to do anything more advanced that involves history state functions, this might not be the plugin for you.
- Download the latest release from here (or
npm install jquery-backdetector
bower install jquery-backdetect)
- Copy either
jquery.backDetect.min.jsto your scripts folder
- Include the script after you call on
|All ✔||All ✔||All ✔||All ✔|
Can append to any element or class:
You can set a delay intiate the back detect. Very similar to setting the time in setTimeout:
; // <- 1 second delay
|The length of time it takes for the backDetect plugin to fire and monitor when a user hits the back button.|
1.0.2 Added backDetect to
1.0.1 Removed the need for the 1x1.png image for IE.
__ _,..,_ (, ) .,' `,./ .' :`.----.': `, : : ^ ^ : ; : : 6 6 : ; : : : ; : : __ : ; < MIT > : `:'.--.`:' ; `. : o o : .' : `----' : : . :'`: . : `.:.' `.:.'