您好,欢迎访问一九零五行业门户网

JavaScript把数组转换为本地字符串的方法toLocaleString()

定义和用法
把数组转换为本地字符串。
语法
arrayobject.tolocalestring()
返回值
arrayobject 的本地字符串表示。
说明
首先调用每个数组元素的 tolocalestring() 方法,然后使用地区特定的分隔符把生成的字符串连接起来,形成一个字符串。
实例
<script type="text/javascript"> var arr = new array(3) arr[0] = "george" arr[1] = "john" arr[2] = "thomas" document.write(arr.tolocalestring()) </script>
输出:
george, john, thomas
此代码用来学习javascript的tolocalestring方法,使用js的tolocalestring方法获取当前的电脑时间,并将结果:“当前本地系统时间为:”显示在网页的主体body区域内。
<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=gb2312"> <title>使用tolocalestring获取本地时间</title> </head> <body background="temp.jpg"> <script language="javascript"> var now = new date(); hours = now.gethours(); if (hours < 25) { document.write("<font size = 6pt face = 黑体 color = ff9900>"+"当前本地系统时间为:"+now.tolocalestring()+"</font>"); } </script> </body> </html>
以上就是javascript把数组转换为本地字符串的方法tolocalestring()的详细内容。
其它类似信息

推荐信息