Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do browsers localize the OK and Cancel buttons of the javascript confirm popup?

Tags:

In a multi-language web site, can I rely on the javascript confirm to translate the text of the Ok/Cancel buttons? If so, is it related to the browser or OS language setting?

like image 294
Greg Avatar asked Dec 14 '09 15:12

Greg


People also ask

What JavaScript method shows a pop up window with OK and Cancel buttons?

The confirm() method displays a dialog box with a message, an OK button, and a Cancel button.

How does confirm work in JavaScript?

The confirm() method is used to display a modal dialog with an optional message and two buttons, OK and Cancel. It returns true if the user clicks “OK”, and false otherwise. It prevents the user from accessing other parts of the page until the box is closed. message is the optional string to be displayed in the dialog.

Which JS method shows two buttons OK and Cancel?

Confirmation Dialog Box It displays a dialog box with two buttons: OK and Cancel. If the user clicks on the OK button, the window method confirm() will return true.

What is confirm box in JavaScript?

A confirm box is often used if you want the user to verify or accept something. When a confirm box pops up, the user will have to click either "OK" or "Cancel" to proceed. If the user clicks "OK", the box returns true. If the user clicks "Cancel", the box returns false.


2 Answers

The OK/Cancel button in Internet Explorer will obey the Operating System UI language settings.

The technical reason is that IE is using the MessageBox Win32 API call to display its Javascript dialog box. That API relies on the OS UI language and not the browser UI language, as it is owned by the OS.

As for 3rd party browsers, it really depends if they are using MessageBox or not to display their box. If they are, it will obey to the Operating System language, if not, it will obey to the browser UI language.

EDIT: Firefox and Chrome are not using MessageBox so technically they should be following the browser UI language settings, though I don't have a french install to test it on. CONFIRMED


If you must localize your buttons, your best bet would be a modal DHTML dialog.

like image 115
Andrew Moore Avatar answered Jan 02 '23 22:01

Andrew Moore


My OS language is French and the OK and Cancel buttons are in french so the answer is : yes!

IE :

removed dead ImageShack link

Firefox :

removed dead ImageShack link

Chrome :

removed dead ImageShack link

like image 43
Olivier Payen Avatar answered Jan 02 '23 23:01

Olivier Payen