faqts : Computers : Programming : Languages : JavaScript : Forms : TextAreas/TextFields

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

4 of 22 people (18%) answered Yes
Recently 1 of 10 people (10%) answered Yes

Entry

Can I (and if so, how) change the weight of a specific selection of text inside a textarea. (ie. can I have both BOLD and NORMAL text in SAME box?

Dec 26th, 2001 01:23
Duvoor Kirthi, mark M, yes by using a iframe


I am not sure if u can do this using a text box
but u can get the same functionality using a iframe which is supported
only by ie4+.i think NN 6 also supports it.
Below is the code for doing this.

html>
<head>
<script>

function Editor()
{
this.Instantiate = EditorInstantiate;
}

function EditorInstantiate()
{
var html = "";
		html += "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"
width=\"100%\">";
		html += "<tr>";
		html += "<td>";
		html += "<iframe id=\"comp1\" width=\"100%\" height=\"190\">";
		html += "</iframe>";
		html += "</td>";
		html += "</tr>";
		html += "</table>";
		
		
		document.write(html);

		html = '';
		html += '<body style="font:10pt arial">';
		html += '</body>';
		comp1.document.open();
		comp1.document.write(html);
		comp1.document.close();
 
		comp1.document.designMode = "on";
		
}
function setVal()
{
comp1.document.execCommand("bold");
}
</script>
</head>