Skip to content

Instantly share code, notes, and snippets.

@Ruxton
Created October 10, 2013 08:58

Revisions

  1. Ruxton created this gist Oct 10, 2013.
    11 changes: 11 additions & 0 deletions somejs.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    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;
    }
    };