By default, there are two buttons:"ok" and "cancel" in confirm().
Is there a way to rename them?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
You can't change the buttons of the default confirm popup. A workaround is to recreate the whole popup in JavaScript. One such workaround is http://jqueryui.com/dialog/#modal-confirmation
http://dev.w3.org/html5/spec-preview/user-prompts.html#simple-dialogs
According to the standard that defines
confirm()
, there is no way to specify custom button labels.The browser must display an OK/Cancel prompt to comply with HTML5.
No, there isn't. Confirm only takes one argument and that is the message itself.
http://dev.w3.org/html5/spec-preview/user-prompts.html#dom-confirm
Keep in mind these dialogs are modal and blocking, which means once they are executed you lose control over the program flow. You'd be on a safer route if you implemented your dialogs using a javascript library of your choice or building yours.
There is a way IF you use a custom modal to confirm. Something like that: