'onbeforeunload not/not correct working in Javascript
I'm trying to use the onbeforeunload or onunload event or even in a:
window.addEventListener('beforeunload', function(){alert("3");}, false);
but it doesn't work, neither on Chrome nor on Firefox, the only method that works is the code below, but the problem is that it works at the start of loading and not when the page being closed, I spent more than 24 hours just with that, and I can't get it to work.
window.onbeforeunload = closefct();
function closefct(e){
alert("5");
console.log("5");
return null
}
Solution 1:[1]
alert will be ignored by the browser. Use console.log to check if it is working properly.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Anastasios Tsournos |
