我js都是放在本aspx的,還沒獨立寫一個js的文件呢。

解决方案 »

  1.   

    编码!!
    <html><body>
    //对中文字符的安全编码转换
    <textarea id="txt"  style="width: 100%; height: 200px" onfocus="this.select()" onblur="mm(this.value)" ></textarea><br/>
    <textarea id="show" style="width: 100%; height: 200px" onfocus="this.select()" ></textarea>
    <SCRIPT LANGUAGE="JavaScript"><!--
    function mm(str)
    {
        var sw = document.getElementById("show");
        if(str==""){sw.value=""; return; }
        var a = str.split(""); //author: meizz
        for(var i=0; i<a.length; i++)
        {
            if(/[\u4e00-\u9fa5\uf900-\ufa2d\uFE30-\uFFA0]/.test(a[i]))
            {
                a[i] = "\\u"+ a[i].charCodeAt(0).toString(16);
            }
        }
        sw.value = a.join("");
    }
    //--></SCRIPT>
    <body></html>
      

  2.   

    謝謝meizz(梅花雪) ,很難得看到你的回復