Window Confirm() Method - W3Schools
Có thể bạn quan tâm
Examples
Display a confirmation box:
confirm("Press a button!"); Try it Yourself »Confirmation box with line-breaks:
confirm("Press a button!\nEither OK or Cancel."); Try it Yourself »More examples below.
Description
The confirm() method displays a dialog box with a message, an OK button, and a Cancel button.
The confirm() method returns true if the user clicked "OK", otherwise false.
Note
A confirm box is often used if you want the user to verify or accept something.
A confirm box takes the focus away from the current window, and forces the user to read the message.
Do not overuse this method. It prevents the user from accessing other parts of the page until the box is closed.
See Also:
The alert() Method
The prompt() Method
Syntax
confirm(message)Parameters
| Parameter | Description |
| message | Optional.The text to display in the confirm box. |
Return Value
| Type | Description |
| A boolean | true if the user clicked OK, otherwise false. |
More Examples
Display a confirmation box, and output what the user clicked:
let text; if (confirm("Press a button!") == true) { text = "You pressed OK!"; } else { text = "You canceled!"; } Try it Yourself »Browser Support
confirm() is supported in all browsers:
| Chrome | Edge | Firefox | Safari | Opera | IE |
| Yes | Yes | Yes | Yes | Yes | Yes |
Từ khóa » Html Javascript Message Box Yes No
-
JavaScript - Create Confirmation Box With Yes And No Options
-
How To Create A Dialog With “Ok” And “Cancel” Options - Stack Overflow
-
Confirm Yes Or No With JavaScript - Code Tutsplus
-
Alert Yes No With The Confirm() Function In JavaScript | Delft Stack
-
Confirm Box In JavaScript With Yes No Option - Tutorial - By EyeHunts
-
Javascript Yes No Alert Box Code Example
-
Html Alert Yes No Code Example
-
Confirmation Box With Yes Or No Button In JavaScript
-
Java Script Alert Yes No - How To Create A Dialog With ... - Pakainfo
-
How To Create A Dialog With “yes” And “no” Options In JavaScript?
-
JavaScript Message Boxes: Alert(), Confirm(), Prompt()
-
nfirm() - Web APIs - MDN Web Docs
-
How To Alert In JavaScript With Yes / No - YouTube
-
Messagebox Of Yes/No Using Javascript - MSDN - Microsoft