jQuery Plugin To Pop To Another URL On Page Exit - Exitpop
File Size: | 39.9 KB |
---|---|
Views Total: | 2903 |
Last Update: | |
Publish Date: | |
Official Website: | Go to website |
License: | MIT |

Exitpop is a jQuery plugin that popups a native confirm dialog on page exit (onbeforeunload) and jumps to another specific URL when you click 'stay on the current page'.
How to use it:
1. Include the jQuery javascript library and jQuery Exitpop plugin in the Html document.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script src="src/jquery.exitpop.js"></script>
2. Initialize the plugin. Set the custom message that appears in the confirm dialog and specify the URL you would like to pop to.
$(document).ready(function(){ $.exitpop({ "url" : "https://www.jqueryscript.net", "message" : "I'm a message" }); });
3. Ignore Html elements.
$(document).ready(function(){ $.exitpop({ ignore : null // Selector or jQuery object of elements to ignore }); });
4. Full plugin options.
// URL to pop to url : "", // Message to display message : "", // Selector or jQuery object of elements to ignore ignore : null, // Custom callback to call callback: $.noop()
Change logs:
2015-04-14
- Add ability to give custom callback to run
2014-11-09
- Bug fixes and simplify code
2014-09-24
- Change logic for html5Handler
This awesome jQuery plugin is developed by tomgrohl. For more Advanced Usages, please check the demo page or visit the official website.