I would like to execute a function before leaving page without showing a confirmation popup with Javascript only. I've tried with the code below but it didn't work or with the onbeforeunload
but it always shows the popup.
var result = 'test';
if(window.onbeforeunload == true)
{
result = 'test1';
alertmess();
}
function alertmess() {
alert(result);
}
//window.onbeforeunload = function() {
// return result;
//}