67,538
社区成员
发帖
与我相关
我的任务
分享
function getLength(str)
{
var length = 0;
for(i = 0;i < str.length; i++)
{
var iCode = str.charCodeAt(i);
if((iCode >= 0 && iCode <= 255) || (iCode >= 0xff61 && iCode <= 0xff9f))
{
length += 1;
}
else
{
length += 2;
}
}
return length;
}
if(navigator.userAgent.toLowerCase().indexOf("ie") == -1 && iCode == 10)
{
length += 1;
}