Search code examples
javascriptcenter

Centering Pop Up Message - Javascript


How can I put this popup error message at the center of my webpage? Here is my code:

    echo "<script language=\"JavaScript\">\n";
    echo "alert('User does not exist!');\n";
    echo "window.location='login.php'";
    echo "</script>";

thank you!


Solution

  • You cannot change the position of browser alert messages or any other browser dialogs. The solution is to implement your own dialog windows or use external libraries like ALERTIFY.js. Please read this question as well: Javascript alert position not in center in chrome.