日期:2014-05-16  浏览次数:20363 次

大侠们帮我看看这个程序,为啥在谷歌火狐狸不起作用啊
IE里运行挺正常的,为啥谷歌、火狐里那右上角数字就是不根据内容变呢?拜托各位拉

JScript code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>无标题页</title>
</head>
<body>
<div class="message_board">
                <label>留言板</label>
                <label>您还可以输入<span id="message_tips_num">140</span>字</label>
                <form name="message_form" action="" method="post">
                    <textarea name="message_input" id="message_input" cols="100" rows="4" ></textarea>
                </form>
</div>
<script>
var oTipsNum=document.getElementById("message_tips_num");
var oTextarea=document.getElementById("message_input");
var nTextareaFocus=0;
var nNumTimer=null;

oTextarea.onfocus=function(){
    nNumTimer=setInterval(function(){
        oTipsNum.innerHTML=140-oTextarea.innerHTML.length;
        if(oTextarea.innerHTML.length>140){
            oTipsNum.style.color="red";
            oTextarea.style.color="white";
            oTextarea.style.backgroundColor="rgb(255,168,168)";
        }
        else{
            oTipsNum.style.color="";
            oTextarea.style.color="";
            oTextarea.style.backgroundColor="rgb(204,232,207)";
        }
    },30);
    nTextareaFocus=1;
}
oTextarea.onblur=function(){
    if(nTextareaFocus==1){
    clearInterval(nNumTimer);
    nTextareaFocus=0;
    nNumTimer=null;
    }
}
</script>
</body>
</html>





------解决方案--------------------
JScript code
//oTipsNum.innerHTML=140-oTextarea.innerHTML.length;
oTipsNum.innerHTML=140-oTextarea.value.length;