Hola, ps te dejo un pequeño ejemplo, pruebalo en
Firefox:
html:
Código HTML:
<script type="text/javascript">
function insertCara(th){
var fig = th.value;
var text = document.getElementById('texto');
var pos = text.selectionStart;
var val = text.value;
var tempText1 = val.substr(0, pos);
var tempText2 = val.substr(pos);
text.value = tempText1 + fig + tempText2;
};
</script>
<input type="button" onclick="insertCara(this);" value=":]" />
<input type="button" onclick="insertCara(this);" value=":D" />
<input type="button" onclick="insertCara(this);" value="xD" />
<br>
<textarea id="texto">Hola amigo
como estas
Adios</textarea>
Eso se puede mejorar ovio, pero es un simple ejemplo para que entidas como se hace
saludOss
:D