请教以下这行JS怎么改成FIREFOX兼容?希望可以在现代码上尽可能少的修改,谢谢<script type="text/javascript">
var maxLen = 180;
function check(obj){
    if(obj.value.length > maxLen){
        obj.value = obj.value.substring(0,maxLen);
        }
     document.getElementById('otext').innerHTML = maxLen - obj.value.length;   
}
</script><table border="0" cellspacing="0" cellpadding="0">
  <form id="tform" name="tform" method="post" action="save.asp">
  <tr>
    <td><textarea id="content" name="content" cols="85" rows="4" onpropertychange="check(this)"></textarea></td>
  </tr>
  <tr>
    <td><input name="button" type="submit" class="button" id="button" value="确认发表" />&nbsp;&nbsp;&nbsp;&nbsp;(你还可以输入 <span id="otext">180</span> 个字)</td>
  </tr>
  </form>
</table>

解决方案 »

  1.   

    如果紧紧要兼容FF的话
    在这段加上
    <textarea id="content" name="content" cols="85" rows="4" onpropertychange="check(this)" oninput="check(this);"> </textarea>
      

  2.   


    <script type="text/javascript"> 
    var maxLen = 180; 
    function check(obj){
        if(obj.value.length > maxLen){ 
            obj.value = obj.value.substring(0,maxLen); 
            } 
        document.getElementById('otext').innerHTML = maxLen - obj.value.length;  
    }
    window,onload=function(){
      if(!document.all){
          document.getElementById('content').addEventListener("input",function(){check(document.getElementById('content'))},false);
      }
    }
    </script> <table border="0" cellspacing="0" cellpadding="0"> 
      <form id="tform" name="tform" method="post" action="save.asp"> 
      <tr> 
        <td> <textarea id="content" name="content" cols="85" rows="4" onpropertychange="check(this)"> </textarea> </td> 
      </tr> 
      <tr> 
        <td> <input name="button" type="submit" class="button" id="button" value="确认发表" />&nbsp;&nbsp;&nbsp;&nbsp;(你还可以输入 <span id="otext">180 </span> 个字) </td> 
      </tr> 
      </form> 
    </table>
      

  3.   

    学习了 同时参考http://www.cnitblog.com/flashlizi/archive/2007/11/13/36226.aspx
      

  4.   

    改成用jquery的吧,兼容性的问题都给解决了的
      

  5.   


    不能保证,要不你就改成onkeyup这个来判断
      

  6.   

    用onkeyup好像同时支持IE/FF/CHROME?