I need to add an alert before the page closes and all online searches say to directly assign to window.onbeforeunload, as in window.onbeforeunload = function(), and return a string, but this is not working for me no matter what I do.
function unload(evt) {
return "UNLOAD";
};
console.log("SET1")
window.addEventListener('beforeunload', unload)
window.onbeforeunload = unload;
console.log("SET2");
This issue is ocurring in chrome specifically