Вы находитесь на странице: 1из 2

<script type="text/javascript" language="JavaScript">

function expandTextAreas(){
var
var
var
var
var
var
var
var
var

ta;
cnt;
x_size;
l_tadiv;
parentNode;
old_node;
ta_width;
ndiv;
re_nlchar;

var objTa = document.getElementById("content").getElementsByTagName('textarea');


var j = objTa.length;
parentNode = this.document.getElementById("content");
alert( 'Test' );
while(j){
--j;
ta = objTa[j];
/* Note that FireFox needs a save or a roundtrip before it can access the conte
nts here! */
cnt = ta.value;
/* In order to keep the formatting as much as possible, replace all line breaks
by HTML*/
var text = escape(cnt);
if(text.indexOf('%0D%0A') > -1){
re_nlchar = /%0D%0A/g ;
}else if(text.indexOf('%0A') > -1){
re_nlchar = /%0A/g ;
}else if(text.indexOf('%0D') > -1){
re_nlchar = /%0D/g ;
}
cnt = unescape( text.replace(re_nlchar,'<br />') );
/* Also let them add paragraphs */
text = escape(cnt);
if(text.indexOf('%B6') > -1){
re_nlchar = /%B6/g ;
}
cnt = unescape( text.replace(re_nlchar,'<p></p>') );
x_size = ta.offsetWidth - 10;
if ( "" == cnt ){
/* Try a different way to access the contents of TA in case it could not be foun
d */
cnt = ta.innerHTML;
}
if ( x_size == 0 ){
/* Assume a length if it could not be determined */
ta_width = "90%";
}else{
ta_width = x_size+"px";

}
/* Please uncomment the following line in case */
/* you want to have the width always set to 80% of the page size */
/* ta_width = "80%"; */
l_tadiv = this.document.createElement('div');
/* CSS Formatting of the textarea replacements */
l_tadiv.style.display
= "block";
l_tadiv.style.zIndex="9000";
l_tadiv.style.background = "white";
l_tadiv.style.padding = "1em";
l_tadiv.style.margin = "1em";
l_tadiv.style.border = "solid 1px Scrollbar";
l_tadiv.style.width = ta_width;
l_tadiv.id = "ta_replacement_"+j;
l_tadiv.innerHTML = cnt;
ta.parentNode.replaceChild(l_tadiv,ta);
}
ta = null;
cnt = null;
x_size = 0;
l_tadiv = null;
parentNode = null;
old_node = null;
ta_width = 0;
ndiv = null;
re_nlchar = null;
}
</script>
<%
* Start all scripts in the order needed
%>
<script type="text/javascript" language="JavaScript">
thtmlbRegisterOnLoad(ppStartScripts);
function ppStartScripts(){
/*Add in this block the call of the new function defined above:*/
expandTextAreas();
}
</script>

Вам также может понравиться