字元轉ascii碼:用charCodeAt();
ascii碼轉字元:用fromCharCode();
看一個小例子
<script><BR>str="A";<BR>code = str.charCodeAt(); <BR>str2 = String.fromCharCode(code);<BR>str3 = String.fromCharCode (0x60 26);
<P>document.write(code '<br />');<BR>document.write(str2 '<br />');<BR>document.write(str3);<BR></script>
輸出:
65
A
z