Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to capture the alert ok button click event?

Is there a way to capture the alert ok button click event? In jQuery?

like image 316
Aperture Avatar asked Jul 24 '12 22:07

Aperture


People also ask

How to access ok button in alert in JavaScript?

To click on the Ok button on alert, first of all we have to switch to alert with switchTo(). alert() method. Next, to click on the Ok button, we have to use accept() method.

How do you alert something in JavaScript?

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.


1 Answers

Alert is a blocking function, means, if you don't close it, the code below will not execute. So you don't have to capture the alert close event, just write down the code below that alert, when alert window will be closed the code below will be executed automatically.

See example below:

alert("Close Me");
// Write down the code here, which will executed only after the alert close
console.log("This code is executed after alert")
like image 161
Vivek Tomar Avatar answered Oct 11 '22 21:10

Vivek Tomar