【javascriptテキストにぶら下がっtextarea】自適応に随行した内容を高度成長縮む

August 13, 2011

方法1、< !doctype html public " – // w3c // dtd 1 . 1 xhtml // en "と"http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtdだった">
< html xmlns "http://www.w3.org/1999/xhtmlだった" >
< html >
< head >
< meta http – equiv " content – type " content " text / html;charset = utf−8 " >
<タイトル>かえで芸能志& raquo;テキストにぶら下がっtextarea高度自適応成長/伸</タイトル>
< style >
textarea { height:100px;width:300px;}
</ style >
</ head >
< body >
< !——以下のコードのうちonpropertychange:ieサポート;oninput:firefoxサポート;互換性のために,ieやffだったので、この2つを眺めていた;–>
< textarea id = " txtcontent " rows = " 1 " onpropertychange " resizetextarea()" oninput " resizetextarea()" onkeyup " resizetextarea()" >晴かえで製作されている
http://witmax.cn </ textareaだった>
< script type " text / javascript " >
//最小の高さです
里香minheight = 100;
最大の高さ、/以上はスクロール件に上っている
里香maxheight = 300;
歌詞resizetextarea(){
里香t = document . getelementbyid(‘ txtcontent ‘);
h = t.s crollheight;
h = h > minheightだったのだろうか。h:minheight;
h = h > maxheightだったのだろうか。maxheight:h;
t.s tyle . height = h +」px ";
}
</ script >
</ body >
</ html >

方法2、

< !doctype html public " – // w3c // dtd 1 . 1 xhtml // en "と"http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtdだった">
< html xmlns "http://www.w3.org/1999/xhtmlだった" >
< html >
< head >
< meta http – equiv " content – type " content " text / html;charset = utf−8 " >
<タイトル>かえで芸能志& raquo;テキストにぶら下がっtextarea高度自適応成長/伸</タイトル>
</ head >
< body >
< textarea id = " txtcontent " rows " 5」cols " " resizetextarea onkeyup 50」()" style " overflow – y:hidden起。> textareaアン・ジェヨル内容は、適応に高度成長するためには、無スクロール件に上っている
晴かえで制作
http://witmax.cn </ textareaだった>
< script type " text / javascript " >
//最小の高さです
里香minrows = 5;
最大の高さ、/以上はスクロール件に上っている
里香maxrows = 12;
歌詞resizetextarea(){
里香t = document . getelementbyid(‘ txtcontent ‘);
if(t.s crolltop = 0)t.s crolltop = 1;
crolltop(t.s while = 0){
if(t.r ows > minrows)
t.r——。ows;
e
break;
t.s crolltop = 1;
if(t.r ows < maxrows)
t.s tyle . overflowy " " hidden;
if(t.s crolltop > 0){
t.r ows++;
break;
}
}
t.s crolltop while(0){ >
if(t.r ows < maxrows){
t.r ows++;
if(t.s crolltop = 0)t.s crolltop = 1;
}
e {
t.s tyle . overflowy " auto ";
break;
}
}
}
</ script >
</ body >
</ html >

本稿のアンディhttp://witmax.cn/javascript-textarea-auto-grow.htmlだった


Leave a Reply

You must be logged in to post a comment.