Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

window.confirm take the cancel button out

How do I take the cancel Button from the window.confirm?? Is there a way to taking it out and only the OK button will show up?

like image 942
user2242573 Avatar asked Apr 05 '13 07:04

user2242573


People also ask

Can we customize window confirm?

You can't, dialogs like confirm and alert are built into the browser and use native OS stylings. Is there a way we can do it in javascript? No, JavaScript cannot affect those dialogs. They are a part of the browser UI, not the webpage.

What does Window confirm do?

window. confirm() instructs the browser to display a dialog with an optional message, and to wait until the user either confirms or cancels the dialog.

How do I change the button text in confirm box?

Change Button Label Using jQuery and CSS We have learned to change the label of the button of the confirm box by creating the custom confirm box. Also, we can use the custom libraries to style the confirm box. Now, we can set the button label in confirm box according to the confirmation message.

What value is returned when a confirm box is Cancelled?

Confirm Box If the user clicks "Cancel", the box returns false.


1 Answers

If you don't want a cancel button, you might as well just use alert():

alert('This operation is not possible');

In beautiful ascii art it looks like this:

+-----------------------------------+
|                                   |
|  This operation is not possible   |
|                                   |
|            +--------+             |
|            |   OK   |             |
|            +--------+             |
+-----------------------------------+

When either OK is clicked or the dialog is dismissed, the next statement in your code will be executed.

If the next statement should be conditional, you'd have to stick with confirm() unfortunately.

like image 83
Ja͢ck Avatar answered Sep 19 '22 04:09

Ja͢ck