Skip to content

Instantly share code, notes, and snippets.

@Ruxton
Created October 10, 2013 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ruxton/6915262 to your computer and use it in GitHub Desktop.
Save Ruxton/6915262 to your computer and use it in GitHub Desktop.
Confirm bandcamp window close if playing
window.onbeforeunload = function () {
var shouldConfirmClose = ($('.playing').length > 0); //get boolen value
if (shouldConfirmClose) {
//this will alert user
return 'Are you sure?';
}
else {
//this wont
window.onbeforeunload = undefined;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment