如何解決中文在js的傳輸問題 我js都是放在本aspx的,還沒獨立寫一個js的文件呢。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 编码!!<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> 謝謝meizz(梅花雪) ,很難得看到你的回復 tr_onclick以后交替变色的问题? 高分求救,快呀! 紧急求救 怎样使TEXT失效? 关闭弹出窗口刷新父窗口的怪问题! 这段代码为什么不对? 求助阿~!!在线等待~!!谢谢大家~! 如何用java script实现打印出页面的一部分?给分 jse文件是怎么回是? javascript中怎样给二维数组赋值? 在一个div中加入一个iframe,在iframe中加入一个button 当响应button的onclick="window.top.document.getElementById('DivID').style.vis 用js在表单提交前替换,太难了
<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>