echo "<html>";
echo "<head>";
echo "<script>";
echo " function logout()";
echo " {";
echo " var r=confirm(\"Are you sure you want to logout?\");";
echo " if (r==true){window.location.href=\"http://www.google.com\";}";
echo " }";
echo "</script>";
echo "</head>";
echo "<body>";
echo "<div ALIGN=\"right\" onclick=\"logout();\"> <a href=\"\">Logout </a> </div>";
echo "</body>";
echo "</html>";
From the above code, I just want to redirect the user to www.google.com
once the user click "YES" in the confirm box. I tried to alert right after (r == true
), it works, however the page doesn't go to www.google.com
. May I know what I've missed out?