Skip to content

Instantly share code, notes, and snippets.

@pascallaliberte
Last active December 31, 2015 07:09
Show Gist options
  • Save pascallaliberte/7952294 to your computer and use it in GitHub Desktop.
Save pascallaliberte/7952294 to your computer and use it in GitHub Desktop.
FluidSurveys: Prompting the user to "Save and continue later" before closing the window.
// 1. Add a question of type "javascript" to your survey (ultra package or higher required)
// 2. Paste this code in and edit the message.
$(function(){
//place script here
$(window).bind('beforeunload', function(){
return 'Just to make sure, did you click "Save and continue later"? We\'re checking because we wouldn\'t want you to lose what you entered.';
});
$('input[type=submit]').click(function(){
$(window).unbind('beforeunload');
});
});
@pascallaliberte
Copy link
Author

One issue: it won't work on the iPad, if the user closes the Safari tab. :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment