Monday, 9 September 2013

Php Javascript redirect issue

Php Javascript redirect issue

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 doesnt go to www.google.com. May I
know what I've missed out?

No comments:

Post a Comment