jquery ask before reloading page code example

Example 1: js ask before close

window.onbeforeunload = function() {
        return "";
  }

Example 2: javascript before reload page alert

<script type="text/javascript">
 window.onbeforeunload = function () {
  return 'Are you really want to perform the action?';
 }
</script>

Example 3: notice before reload js

<script>
  // Warning before leaving the page (back button, or outgoinglink)
window.onbeforeunload = function() {   
  return "Do you really want to leave our brilliant application?";   
  //if we return nothing here (just calling return;) then there will be no pop-up question at all   
  //return;
};
</script>