Reputation: 11605
this current piece of script to confirm whether a user wants to log out is not fully working in Safari on Mac.
function log_out()
{
ht = document.getElementsByTagName("html");
ht[0].style.filter = "progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)";
if (confirm('Are you sure you want to log out?'))
{
return true;
}
else
{
ht[0].style.filter = "";
return false;
}
}
It works when the user confirm they want to logout, Ok, but when the user clicks cancel, they are still logged out.
Any ideas?
Thanks in advance!
Upvotes: 3
Views: 2730
Reputation: 382656
Ok, but when the user clicks cancel, they are still logged out.
After seeing your code in the comment you posted:
<a class="rnavtab" href="?do=logout" onclick="log_out()">Log out</a>
The ?do=logout
is triggered irrspective of whether a user confirms or not. Try putting a hash instead:
<a class="rnavtab" href="#" onclick="log_out()">Log out</a>
You can later on redirect user like this:
window.location = '?do=logout';
Upvotes: 1
Reputation: 18522
Put the return instruction in front of the log_out call
<a class="rnavtab" href="?do=logout" onclick="return log_out()">Log out</a>
Upvotes: 3