totalmente crossbrowser e' impossibile
codice:
function addSml(sml) {
var obj=document.mioform.msg;
if (document.all) {
obj.focus();
var sel=document.selection;
var rng=sel.createRange();
rng.colapse;
rng.text=sml;
} else if(obj.selectionEnd){
var lng=obj.textLength;
var from=obj.selectionStart;
var to=obj.selectionEnd;
obj.value=obj.value.substring(0,from)+sml+obj.value.substring(to,lng)
} else obj.value+=sml;
obj.focus();
}
codice:
<form name="mioform">
<textarea name="msg"></textarea>
<input type="button" value=":)" onclick="addSml(':)')" />
</form>