var ask = truewindow.onbeforeunload = function (e) { if(!ask) return null e = e || window.event; //old browsers if (e) {e.returnValue = 'Sure?';} //safari, chrome(chrome ignores text) return 'Sure?';};
123456789