Samuel Cotinguey Jr.
Samuel Cotinguey Jr.

Reputation: 15

how to move to another page after displaying JavaScript alert

How can I move to another page after displaying the JavaScript alert. Thank you, :D What's the next code for this to go to another page?

if(isset ($_POST['reply'])){

    echo "<script>alert('Login to continue.')</script>";

}

Upvotes: 2

Views: 90

Answers (3)

Devsi Odedra
Devsi Odedra

Reputation: 5322

Hope you are looking for this

echo "<script>alert('Update Not Successfully');document.location='pagename.php'</script>";

do not forget to write script at start and end point in echo.

Upvotes: 1

Hassaan
Hassaan

Reputation: 7672

You must use JavaScript confirm and window.location both for it.

var r = confirm("Login to continue.");
if (r == true)
{
    window.location = "http://www.domain.com/agreed.html";
}
else
{
    window.location = "http://www.domain.com/cancelled.html";
}

Upvotes: 0

Chonchol Mahmud
Chonchol Mahmud

Reputation: 2735

You can use javascript below way:

window.location = "http://www.domain.com";

Also you can try with PHP code:

header('Location: targetPage.php');

Upvotes: 0

Related Questions