qwerty
qwerty

Reputation: 183

redirect after alert box

I want to redirect page after clicking an alert box "OK" button

This is my code, but this is not working. The alert box is coming up but when I press OK button it redirects to the same page. I want to redirect http://localhost/project/index.php/Con_Group_View this page.

else
{
    echo '<script type="text/javascript">';
    echo'alert("Your Group Already Created ");';
    echo 'window.Location="http://localhost/project/index.php/Con_Group_View";';
    echo '</script>';
}

Upvotes: 3

Views: 4630

Answers (2)

Sherif
Sherif

Reputation: 11943

You want window.location.href = "http://localhost/project/index.php/Con_Group_View" not window.Location. Remember, names are case-sensitive in javascript.

Also note this is a duplicate of How to redirect to another webpage in JavaScript/jQuery?

Upvotes: 2

Velko Georgiev
Velko Georgiev

Reputation: 694

It is

echo '<script type="text/javascript">';
echo'alert("Your Group Already Created ");';
echo 'window.location = "http://localhost/project/index.php/Con_Group_View";';
echo '</script>';

JavaScript is case-sensitive, there is a difference between window.location and window.Location

Upvotes: 1

Related Questions