简体   繁体   中英

How to change OK/Cancel button's text in browsers to desired text?

Is there a way to change confirmation's button text to desired text? (YES/NO or OK/CANCEL)
My language is not English and this issue has really spoiled the site UI?

EDIT
I'm using JavaScript in my PHP web app to show confirmation dialog boxes.

You can't (for hopefully obvious security reasons).

As for native language, that'd be up to the device OS to support and browser to recognize.

As Jay points out, you could create your own dialogs.

With JavaScript, there are two main ways to handle this.

One:

confirm("Do you like eggs?");

This produces a native confirmation dialog (with affirmative and negative buttons) that the user has to click. If they click in the affirmative, the script continues. If the negative, it ends.

This is the easiest to implement as it leverages native functionality of the browser. It's also what will be natively localized provided the OS and browser support that and the user has set it up.

Two:

The second option is to create your own modal. This is typically done by using JavaScript to update the DOM to mask out the background (usually with a large DIV) and then create a 'pop-up' that would be a DIV styled via CSS. You can then create any interactions you'd like with any wording you'd like. Most of the standards UI JS libraries (such as jQueryUI) now have these as built in components.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM