Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript windows alert with redirect function

.guys I have the following code:

echo ("<SCRIPT LANGUAGE='JavaScript'>
        window.alert('Succesfully Updated')
        </SCRIPT>");

what i want to do is that when i click ok on the windows.alert the page will be redirected to a my edit.php.

or how is it possible to create a javascript which will execute an insert query.

like image 239
zerey Avatar asked Mar 26 '11 16:03

zerey


People also ask

How do I get alert messages after redirecting a page?

For displaying alert message after redirection you may use Session or QueryString and on page Load check if the Session or QueryString is not empty then display alert message.

How will you create an alert window using JavaScript?

The alert() method in JavaScript displays an alert box with a specified message and an OK button. It is often used to make sure that information comes through to the user. The alert box takes the focus away from the current window and forces the browser to read the message.

What does the alert () function in JavaScript do?

One useful function that's native to JavaScript is the alert() function. This function will display text in a dialog box that pops up on the screen. Before this function can work, we must first call the showAlert() function. JavaScript functions are called in response to events.

Does JavaScript alert stop execution?

One of the nice things about the built-in JavaScript alert is that - unlike virtually anything else in JavaScript - it's synchronous. It's completely blocking, and no other code will execute until it's been dismissed.


2 Answers

Alert will block the program flow so you can just write the following.

echo ("<script LANGUAGE='JavaScript'>
    window.alert('Succesfully Updated');
    window.location.href='http://someplace.com';
    </script>");
like image 143
Pickels Avatar answered Oct 20 '22 03:10

Pickels


You could do this:

echo "<script>alert('Successfully Updated'); window.location = './edit.php';</script>";
like image 43
Karl Nicoll Avatar answered Oct 20 '22 02:10

Karl Nicoll