Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/434.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
除了IE,其他浏览器都不能使用Javascript_Javascript - Fatal编程技术网

除了IE,其他浏览器都不能使用Javascript

除了IE,其他浏览器都不能使用Javascript,javascript,Javascript,我有以下代码 <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Automatic Resize TextBox</title> <script type="text/javascript"> function setHeight(txtdesc) { txtdesc.style.height = txtdesc

我有以下代码

  <html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
  <title>Automatic Resize TextBox</title>
  <script type="text/javascript">
  function setHeight(txtdesc) {
    txtdesc.style.height = txtdesc.scrollHeight + "px";
  }
  </script>
  </head>
  <body>
  <form id="form1" runat="server">
  <div>
  <asp:TextBox ID="txtDesc" runat= "server" TextMode="MultiLine"  Onkeyup="setHeight(this);" onkeydown="setHeight(this);" />
   </div>
   </form>
   </body>
   </html>

自动调整文本框大小
功能设置高度(txtdesc){
txtdesc.style.height=txtdesc.scrollHeight+“px”;
}
这是一个javascript,用于在文本框中写入时调整文本框的大小。这意味着如果文本框将完全填充,则它将自动展开,但如果我们删除文本框,则文本框将折叠…在IE中工作正常,但在其他浏览器中不工作请帮助我…


我发现这在Chrome和FF中有效。如果你仍然面临这个问题。在这里写入详细信息并粘贴客户端代码意味着HTML+JS。

您面临的问题是,在IE中,滚动高度仅基于文本区域的内容计算,而在其他浏览器中,它基于可用的内容空间。这意味着设置CSS高度将增加scrollHeight,并防止其向下收缩

这个问题已经出现过很多次了,人们提出的最佳答案似乎是执行一项复杂的任务,即根据文本内容计算有多少行。还有很多人通过搜索


.

我的意思是2,如果我们从文本框中删除文本,它将自动折叠…如果您有客户端问题,则显示客户端代码,而不是在执行时生成客户端代码的服务器端代码。我无法获取您可以给我简单介绍一下吗………停止在文本编辑器中查看ASP。转到浏览器。查看源代码。获取浏览器处理的代码。向人们展示这一点。@user-他说的是在您的示例中使用纯html
input
,而不是asp.net服务器控件
asp:TextBox