TEXTAREA自适应文字行数的多少
<textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posHeight=this.scrollHeight">
</textarea>

解决方案 »

  1.   

    梅老大的很好用。
    <textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posHeight=this.scrollHeight">
    </textarea>
      

  2.   

    那宽度呢?
    <textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posWidth=this.scrollWidth">
    </textarea>
    很奇怪的结果
      

  3.   


    <style>
    textarea{
    font:14px
    }
    </style>
    </head>
    <BODY >
    <iframe frameborder=NO  height="124" width="190" name=kxt scrolling=no src="http://www.cnstock.com/hangqing/hangqing.htm"></iframe>
    <textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posHeight=this.scrollHeight" onclick="alert((this.scrollHeight-2)/16)">
    </textarea>
      

  4.   

    那怎么得到textarea中CSS的font的大小?
      

  5.   

    我再问一个问题??????????
    在JAVASCRIPT中怎么得到屏幕的长度呢(像素)?
      

  6.   

    <script>
    alert(screen.width);  //屏幕区域大小
    alert(screen.availWidth); //屏幕工作区域大小
    </script>
    不好意思!
      

  7.   

    meizz(梅花雪) 的方法可以适应回车,那怎么同时也适应长度呢?
      

  8.   

    而且上面的方法只对IE有用啊,对Mozilla无效