sones,
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
</head>
<body>
<script>
function addedidor(tag, tagEnd)
{
tagEnd = tagEnd || tag.replace(/\s.*/,'');
var obj = document.getElementById('content');
if(document.selection) obj.value += "<" + tag + "></" + tagEnd + ">";
else if(typeof(obj.selectionStart) == "number")
{
var start = obj.selectionStart;
var end = obj.selectionEnd;
var value = obj.value;
obj.select();
if(start != end)
{
obj.value = value.substr(0,start) + "<" + tag + ">" + value.substr(start,end - start) + "</" + tagEnd + ">" + value.substr(end);
obj.setSelectionRange(start,end + tag.length + tagEnd.length + 5);
}
else
{
obj.value = value.substr(0,start) + "<" + tag + "></" + tagEnd + ">" + value.substr(start);
obj.setSelectionRange(start + tag.length + 2,start + tag.length + 2);
}
}
}
</script>
<p align="right">
<input type="button" value='<font color="red"></font>' onClick='addedidor("font color=\"red\"");' >
<input type="button" value='<font color=""></font>' onClick='addedidor("font color=\"\"");' >
<input type="button" value='<a href=""></a>' onClick='addedidor("a href=\"\"");' >
<input type="button" value="<b>" onClick="addedidor('b');" >
<input type="button" value="<i>" onClick="addedidor('i');" >
<input type="button" value="<u>" onClick="addedidor('u');" >
<input type="button" value="<h2>" onClick="addedidor('h2');" >
<input type="button" value="<h3>" onClick="addedidor('h3');" >
<input type="button" value="абзац" onClick="addedidor('p');" >
<input type="button" value="ссылка" onClick="addedidor('a');" >
</p>
<textarea id="content"></textarea>
</body>
</html>