sush sush - 1 year ago 76
Javascript Question

Internationalization(Number formatting "num.toLocaleString()") not working for chrome

i want do number formatting in Javascript.. and i use the following method
num.toLocaleString() which will work for Firefox, IE but doesnt work for Google Chrome..
Wat i need to add for it work in chrome browser.

Answer Source

The toLocaleString() method is by definition implementation-dependent: it uses the implementation locale, such as browser locale. So if I were looking at your page that uses the method, I would see numbers formatted according to Finnish or English locale, depending on which browser I’m using.

What you want is localization by the locale of the page, and for this you need something else. In simple cases you might code it yourself, but number formatting is in general complicated, making it reasonable to use a library, such as Globalize. Check out the compact source of a simple demo. In Globalize, you use standard language codes when specifying the locale.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download