Ok
Comunque prova questo, ho usato la tua immagine "risata.jpg", così capisci cosa intendo...:
codice:
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Esempio per il Forum di HTML.it</title>
<script type="text/javascript">
function insertMetaChar(sStartTag, sEndTag) {
var bDouble = arguments.length > 1, oMsgInput = document.myForm.myTxtArea, nSelStart = oMsgInput.selectionStart, nSelEnd = oMsgInput.selectionEnd, sOldText = oMsgInput.value;
oMsgInput.value = sOldText.substring(0, nSelStart) + (bDouble ? sStartTag + sOldText.substring(nSelStart, nSelEnd) + sEndTag : sStartTag) + sOldText.substring(nSelEnd);
oMsgInput.setSelectionRange(bDouble || nSelStart === nSelEnd ? nSelStart + sStartTag.length : nSelStart, (bDouble ? nSelEnd : nSelStart) + sStartTag.length);
oMsgInput.focus();
}
</script>
</head>
<body>
<form name="myForm">
[img]risata.jpg[/img]</p>
<textarea rows="10" cols="50" name="myTxtArea">Testo di esempio</textarea></p>
</form>
</body>
</html>