JavaScript - "Are you sure you want to leave this page"
<a href="http://stackoverflow.com/questions/7794301/window-onunload-is-not-working-properly-in-chrome-browser-can-any-one-help-me/9325742#9325742">Leave this page!</a>
window.onbeforeunload = function (e) {
console.log(e);
return 'Dialog text here.';
};