Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ianrogren/jquery-backDetect
jQuery backDetect is a jQuery plugin that is used to determine when a user clicks the back button and fire a callback function.
https://github.com/ianrogren/jquery-backDetect
Last synced: about 2 months ago
JSON representation
jQuery backDetect is a jQuery plugin that is used to determine when a user clicks the back button and fire a callback function.
- Host: GitHub
- URL: https://github.com/ianrogren/jquery-backDetect
- Owner: ianrogren
- Created: 2016-03-10T06:15:44.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-16T03:54:36.000Z (over 6 years ago)
- Last Synced: 2024-03-15T01:53:10.314Z (6 months ago)
- Language: CSS
- Size: 32.2 KB
- Stars: 27
- Watchers: 6
- Forks: 25
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
jQuery 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 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.
### Installation
---
- Download the latest release from here (or `npm install jquery-backdetect` or `bower install jquery-backdetect`)
- Copy either `jquery.backDetect.js` or `jquery.backDetect.min.js` to your scripts folder
- Include the script after you call on `jQuery`### Browser Support
| Chrome | Firefox | Internet Explorer | Safari |
| --- | --- | --- | --- |
| All ✔ | All ✔ | All ✔ | All ✔ |### Basic Usage
Can append to any element or class:
``` javascript
$(window).load(function(){
$('body').backDetect(function(){
// Callback function
alert("Look forward to the future, not the past!");
});
});
```### Custom Options
You can set a delay intiate the back detect. Very similar to setting the time in setTimeout:
``` javascript
$(window).load(function(){
$('body').backDetect(function(){
// Callback function
alert("Look forward to the future, not the past!");
});
}, 1000); // <- 1 second delay````
| Settings | Default Value | Description
| --- | --- | --- |
| delay |delay: 0| The length of time it takes for the backDetect plugin to fire and monitor when a user hits the back button.### Change Log
1.0.3 Cleaned up javascript and updated README.md
1.0.2 Added backDetect to `npm` and `bower` repos.
1.0.1 Removed the need for the 1x1.png image for IE.
### Licence
```__
_,..,_ (, )
.,' `,./
.' :`.----.': `,
: : ^ ^ : ;
: : 6 6 : ;
: : : ;
: : __ : ;
< MIT > : `:'.--.`:' ;
`. : o o : .'
: `----' :
: . :'`: . :
`.:.' `.:.'
```