I want to ask the user why he is leaving my page before he leaves. I tried:
window.onbeforeunload = function() {
var answer = prompt("Why do you leave?", "");
if (answer != null) {
send(answer);
}
}
But it doesn't work. There are two problems: I should figure out how to display the prompt box to the user, and also how can I send his answer to the server. Do you have any ideas please?