0
How can I confirm if the user really left the page, because when I click on the browser to exit and say I want to remain it turns the name of mine a
1 and then no longer 0. Does anyone have a solution? Code below:
<!DOCTYPE html>
<html>
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script>
window.onbeforeunload = closeSession;
function closeSession() {
if (true) {
var a = document.getElementById('a');
if (a.name != 1) {
$.ajax({
url: "teste.php",
type: "GET",
async: false,
cache: false,
data: {
'nome' : "Rogers2",
'senha' : "123456"
}
});
return "disconnected";
}
} else {
a.name = 0;
}
}
</script>
<body>
<p>Close this window, press F5 or click on the link below to invoke the onbeforeunload event.</p>
<a href="teste2.php" onclick="this.name = 1" id="a" name="0">teste2</a>
</body>
I have tried this but failed. I thank you anyway.
– Rogers Corrêa
But explain better what you want exactly so I can help you, because from what I understand in the question, you want an exit confirmation page.
– Ivan Ferrer