spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column59


IE 5.5: Formatting, URIs, and Stack Operations

Developer News
OpenOffice 3.2 Lands Amid Critical Changes
Red Hat, IBM Firmly in KVM Virtualization Camp
Red Hat Talks Up Open Source Cloud Plans

Formatting Data by Local Settings

Internet Explorer 5.5 updated the toLocaleString() method for the objects Date, Number, and Array so they all retrieve formatting information from the user's Control Panel settings. The Date printout is determined by the Date tab of the Control Panel's Regional Settings:

and by the Time tab:

If we define x, for example, as:

x = new Date();

then the command alert(x.toLocaleString()) will look like:

Notice how the format is as specified in the Region Settings above.

When printing a number, the format is determined by the Number tab:

Assume that:

x = 1234.56789

Then the simple printout alert(x.toLocaleString())

yields the following prompt box:

Notice how the settings in the Number tab above are reflected in the printout. The specification of the number of digits after the decimal place (2) is a good example.

Let's see now how arrays are printed out. Suppose we have the following JavaScript statement that defines an array:

x= new Array("a", "b", "c");

The statement alert(x.toLocaleString()) generates the following box:

Notice how the elements are separated by commas, as specified in the Number tab above. Let's change the separator character to a $ sign. The alert box will look like this:

Next: How to push and pop array elements

http://www.internet.com

Produced by Yehuda Shiran and Tomer Shiran


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

webref The latest from WebReference.com Browse >
Search Engine Optimization: Selecting and Embedding Keywords · Are Google's Language Translation Web Services Ready for Prime Time? · Installing and Using Meeplace, the Business Review CMS
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
IBM DB2 10 for z/OS: Justifying the Upgrade · Living La Vida Colo: Choosing the Right Colocation Facility · FTC Concerns over Social Media Privacy Linger


Created: March 14, 2000
Revised: April 26, 2000

URL: http://www.webreference.com/js/column59/3.html