发一帖放50分,求文本中的值有多少K,在客户端提交之前,用javascript document.all.txtmsg.value.length/1024;这样子对吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 no no no 不可!~ 涉及安全问题,本地一般不给javascript开放这种权限 <script>function ShowFileSize(filespec){ try{ var fso, f, s; fso = new ActiveXObject("Scripting.FileSystemObject"); f = fso.GetFile(filespec); s = f.Name + " uses " + f.size + " bytes."; return(s); }catch(e){}}</script><input name=fl type="file" value=""><button onclick="alert(ShowFileSize(fl.value))"> sorry,建议首先决定所采用的编码方式,一般来说一个汉字所占的大小是英文字符的两倍,但这一规则在短信这块可能根据编码规范的不同而不能适用,建议参考以下资料---------------------http://www.mcuchina.com/Article/Interface/COM/COMPRG/200411/81.html如果将英文和汉字都视为一个字节,则长度直接取txtmsg.value.length function UpdateText() { alert(document.activeElement.value.replace(/[^\x00-\xff]/g,"**").length/1024);} ext3.4主题切换 在函数中使用全局变量的问题 那些工具能够提示JS语法错误的工具? ie中无法使用document.createElement和appendChild google首页那个加为首页的功能是怎么实现的? 高分求助:如何用JS调用广告脚本代码 怎样取多维数组的长度? jquery easyui 单选按钮的检验 求助,弹出框的问题 text和select联动的问题 放100分帮忙,怎么知道文本,图片,声音等大小多少K,做彩信开发,为了不要超过50K
function ShowFileSize(filespec)
{
try{
var fso, f, s;
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.GetFile(filespec);
s = f.Name + " uses " + f.size + " bytes.";
return(s);
}catch(e){}
}
</script>
<input name=fl type="file" value=""><button onclick="alert(ShowFileSize(fl.value))">
---------------------
http://www.mcuchina.com/Article/Interface/COM/COMPRG/200411/81.html如果将英文和汉字都视为一个字节,则长度直接取txtmsg.value.length
alert(document.activeElement.value.replace(/[^\x00-\xff]/g,"**").length/1024);
}