|
|
|
|
для: 1prom
(03.03.2012 в 21:51)
|
| По-быстрому, на коленке
<!doctype>
<script>
function StTxt () {if (self.TRH) return; MyT = document.getElementById ('myTXT'); with (MyT) {
var tch = clientHeight, vl = value; while (tch >= scrollHeight) value += '\n ';
TR = rows++; TRH = scrollHeight - tch; rows--; value = vl; focus ();
if (window.addEventListener) addEventListener ('input', RszTxtMoz, false);
else attachEvent ('onpropertychange', RszTxtIE, false)}}
function RszTxtMoz () {with (MyT) {rows = TR; if (scrollHeight > clientHeight)
rows = Math.max (TR, TR + (scrollHeight - clientHeight) / TRH)}}
function RszTxtIE () {var r = Math.max (TR, Math.round (MyT.createTextRange ().boundingHeight * MyT.rows / MyT.clientHeight) + 1);
if (MyT.rows != r) MyT.rows = r}
</script>
<textarea id="myTXT" cols="20" rows="5" style="overflow: hidden; resize: none" onfocus="StTxt ()"></textarea>
<!-- ^^^^^ ^^ ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ -->
<!-- | | | | | -->
<!-- обязательно любое любое обязательно обязательно -->
|
| |
|
|