Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JS Confirm, false, return, not working

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!

like image 503
bear Avatar asked Feb 25 '26 07:02

bear


1 Answers

Put the return instruction in front of the log_out call

<a class="rnavtab" href="?do=logout" onclick="return log_out()">Log out</a>
like image 157
Rafael Avatar answered Mar 03 '26 13:03

Rafael