Reputation: 20867
In an Adobe AIR (HTML/JS) app, is it possible to display Yes/No buttons, instead of OK/Cancel in a confirm()
dialog?
Anything that works with webkit should work.
Here's a related question, but all of the answers utilise jQuery, which I don't want to add just for this.
Upvotes: 3
Views: 31679
Reputation: 21359
The closest native solution I can think about is using the new <dialog> element.
The following example is the simplest one taken from the link above, as the dialog is made of HTML you can customize it as you want. Browse the link for advanced examples.
const dialog = document.querySelector("dialog");
const showButton = document.querySelector("dialog + button");
const closeButton = document.querySelector("dialog button");
// "Show the dialog" button opens the dialog modally
showButton.addEventListener("click", () => {
dialog.showModal();
});
// "Close" button closes the dialog
closeButton.addEventListener("click", () => {
dialog.close();
});
::backdrop {
background-image: linear-gradient(
45deg,
magenta,
rebeccapurple,
dodgerblue,
green
);
opacity: 0.75;
}
<dialog>
<button autofocus>Close</button>
<p>This modal dialog has a groovy backdrop!</p>
</dialog>
<button>Show the dialog</button>
Upvotes: 1
Reputation: 882786
I don't believe so. In JS, confirm()
is specified to only use the OK and Cancel buttons.
If you want something more complicated, you'll have to make your own dialog, or use a third-party one that provides your desired functionality (yes, including jQuery, unfortunately).
Upvotes: 3
Reputation: 19103
It's not possible to customise the confirm()
dialog.
There are some suggestions at Javascript Customize Confirm with "Yes" or "No" but it pins down to using jQuery or implementing your own version of the jQuery dialog.
Upvotes: 1