本帖最后由 buxchang 于 2011-07-21 20:23:47 编辑

解决方案 »

  1.   

    <textarea name="word" onpropertychange="this.style.height=this.scrollHeight+'px';" oninput="this.style.height=this.scrollHeight+'px';" style="border:0px;overflow:visible;width:550px;font-size:12px;background-color:#f6f8f9;margin-left:10px; border:solid 1px #E2E2E2;padding:10px 10px;">
      想实现Textarea自动适用高度且无滚动条,以下代码可以在IE下正常工作,在FF下基本功能也正常, 
    但是在FF下有个小问题:高度可自动增长,但是不能减小,请指教: 
    代码说明:onpropertychange:IE支持;  oninput:FireFox支持;为了兼容IE和FF,所以加上了这个两个;
    </textarea>
    <?php 
    echo("word.scrollHeight+'px'");
    ?>付上代码..
      

  2.   

    <textarea name="word" onpropertychange="this.style.height=this.scrollHeight+'px';document.getElementById('show').innerHTML=this.scrollHeight+'px';" oninput="this.style.height=this.scrollHeight+'px';document.getElementById('show').innerHTML=this.scrollHeight+'px';" style="border:0px;overflow:visible;width:550px;font-size:12px;background-color:#f6f8f9;margin-left:10px; border:solid 1px #E2E2E2;height:20px;padding:10px 10px;">
      想实现Textarea自动适用高度且无滚动条,以下代码可以在IE下正常工作,在FF下基本功能也正常, 
    但是在FF下有个小问题:高度可自动增长,但是不能减小,请指教: 
    代码说明:onpropertychange:IE支持;  oninput:FireFox支持;为了兼容IE和FF,所以加上了这个两个;
    </textarea><div id="show"></div>
      

  3.   

    大哥,我要赋值给变量的,把它的高度宽度赋值给变量:$height=word.heiht
      

  4.   

    <textarea name="word" onpropertychange="run(this)" oninput="run(this)" style="border:0px;overflow:visible;width:550px;font-size:12px;background-color:#f6f8f9;margin-left:10px; border:solid 1px #E2E2E2;height:20px;padding:10px 10px;">
      想实现Textarea自动适用高度且无滚动条,以下代码可以在IE下正常工作,在FF下基本功能也正常, 
    但是在FF下有个小问题:高度可自动增长,但是不能减小,请指教: 
    代码说明:onpropertychange:IE支持;  oninput:FireFox支持;为了兼容IE和FF,所以加上了这个两个;
    </textarea><script>
    function run(o){
      var h=o.scrollHeight;
      o.style.height=h+'px'
      document.getElementById('run').src='run.php?height='+h+'';
    }
    </script><iframe id="run" style="display:none" src="run.php"></iframe>
    <div id="show"></div>run.php[code]<?php
    $height=$_GET['height'];
    echo '<script>parent.document.getElementById("show").innerHTML="'.$height.'";</script>';
    ?>
    你想在一个页面让JS和PHP交互,没别的办法。