JS怎样获得某一键的unicode值 本帖最后由 ealzero 于 2011-03-07 21:23:48 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <html><head><script>function decToHex2(str) {//编码 var res="",c; for(var i=0;i < str.length;i++){ c=str.charCodeAt(i); res+=(c< 32 || c==38 || c>127)?"\\u"+c.toString(16):str.charAt(i) } return res} function hexToDec(str) {//解码 str=str.replace(/\\/g,"%"); return unescape(str);} function change(obj){ document.getElementById('CValue').innerHTML = decToHex2(obj.value);}</script></head><body>请输入:<input id="TValue" type="text" onkeyup="change(this)"/><br/>编码后:<span id="CValue"></span></body></html> <script language="javascript"> window.onkeydown = function(e) { alert(e.keyCode); }</script> document.onkeypress=function(e){ var code; if (!e) var e=window.event; if(e.keyCode) code=e.keyCode; else if(e.which) code = e.which; alert(code)}; 如何获取当前li上面最近的ul id值 梅花雪树形菜单复选框问题 javaScript问题!求答案! 关于Extjs开发 急!!!!JS中定义三维变量问题 怎样改变showModelessDialog方法弹出窗口的title?在线等待 如何实现,单击一个按钮,移动一下图片,其中,图片放在表格内? 有没有IE窗口的关闭事件, 怎样写,大家帮帮忙! 我既不想让它弹出对话框,也不想打印到默认打印机上,有什么办法吗? 帮忙解密一段js 服务端可否通过js取得客服端浏览器的窗口大小和位置? js中解析java map型数据的问题
<head>
<script>function decToHex2(str) {//编码
var res="",c;
for(var i=0;i < str.length;i++){
c=str.charCodeAt(i);
res+=(c< 32 || c==38 || c>127)?"\\u"+c.toString(16):str.charAt(i)
}
return res
}
function hexToDec(str) {//解码
str=str.replace(/\\/g,"%");
return unescape(str);
}
function change(obj)
{
document.getElementById('CValue').innerHTML = decToHex2(obj.value);
}</script>
</head>
<body>
请输入:<input id="TValue" type="text" onkeyup="change(this)"/>
<br/>
编码后:<span id="CValue"></span>
</body>
</html>
window.onkeydown = function(e) {
alert(e.keyCode);
}
</script>
{
var code; if (!e) var e=window.event;
if(e.keyCode) code=e.keyCode;
else if(e.which) code = e.which;
alert(code)
};