1,得到字符串長度,非個數
{
var sStr,iCount,i,strTemp ;
iCount = 0 ;
sStr = sString.split( "" );
for (i = 0 ; i < sStr.length ; i ++ )
{
strTemp = escape(sStr[i]);//或者用sStr[i].charCodeAt(0)<299 ?
if (strTemp.indexOf( " %u " , 0 ) == - 1 )
{
iCount = iCount + 1 ;
}
else
{
iCount = iCount + 2 ;
}
}
return iCount ;
}
2, 禁止粘貼到文本框,支持IE,FIREFOX等
{
if(!window.event)
{
var keycode = evt.keyCode;
var key = String.fromCharCode(keycode).toLowerCase();
if(evt.ctrlKey && key == "v")
{
evt.preventDefault();
evt.stopPropagation();
}
}
}
IE中不需要寫οnkeydοwn=fncKeyStop(event)
已知的問題:不能屏蔽Firefox的菜單欄上的“paste”