Question

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!

Was it helpful?

Solution

Put the return instruction in front of the log_out call

<a class="rnavtab" href="?do=logout" onclick="return log_out()">Log out</a>

OTHER TIPS

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';
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top