当前位置: 首页 > 网络学院 > 客户端脚本教程 > JavaScript > JavaScript fromCharCode() 方法

JavaScript
JS 字符串
JS Date
JS数组,JS Array
JS Boolean
JS Math
JS HTML DOM
JS Browser
JS Cookies
JS 校验
JS Animation
JS Image Maps
JS Timing
JS 建立对象
JS 摘要
JS 实例
JS 对象实例
JS DOM 实例
JS数组对象参考
JS布尔对象参考
JS日期对象参考

JavaScript fromCharCode() 方法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 426 ::
收藏到网摘: n/a

Definition and Usage
定义与用法

The fromCharCode() takes the specified Unicode values and returns a string.
fromCharCode()将Unicode码转换为对应的字符并返回为字符串

Syntax
语法

String.fromCharCode(numX,numX,...,numX)

Parameter
参数
Description
注释
numX
Unicode码
Required. One or more Unicode values
必选项。一个或多个Unicode 值


Tips and Notes
注意

Note: This method is a static method of String - it is not used as a method of a String object that you have created. The syntax is always String.fromCharCode() and not myStringObject.fromCharCode().
注意:本方法只适用于静态字符串 - 不能用于你自定义的字符串对象。


Example
实例

In this example we will write "HELLO" and "ABC" from Unicode:
在本例中,我们将通过Unicode码输出"HELLO"和”ABC“:

<script type="text/javascript">
document.write(String.fromCharCode(72,69,76,76,79))
document.write("<br />")
document.write(String.fromCharCode(65,66,67))
</script>

The output of the code above will be:
输出结果为:

HELLO
ABC


Try-It-Yourself Demos
互动演练

fromCharCode()
How to use fromCharCode() to display a string from Unicode values.
如何用fromCharCode()把Unicode码转为对应字符并输出

评论 (0) All

登陆 | 还没注册?