In JavaScript 'confirm()' function is used for this purpose. This method displays a dialog box with a specified message, along with an OK and a Cancel button.
The confirm() method returns true if the user clicked "OK", and false otherwise.
The parameter type of this function is 'String'. This method does not accept HTML string as parameter. For 'line-breaks' please use '\n'.
Demo
The confirm() method returns true if the user clicked "OK", and false otherwise.
The parameter type of this function is 'String'. This method does not accept HTML string as parameter. For 'line-breaks' please use '\n'.
var UserAction = confirm("Are you sure you want to delete?");Final code and demo is here
if (UserAction == true)
{
//User pressed on OK button
}
else
{
//User pressed on CANCEL button
}
Demo
No comments:
Post a Comment