Il suffit de remplacer la function emoticon(text) par
Code : Tout sélectionner
function emoticon(text) {
var txtarea = document.post.message;
text = ' ' + text + ' ';
if (txtarea.selectionEnd >= 0 && txtarea.setSelectionRange) { // XXX Ajout positionnement smilies mozilla
var textLength = txtarea.textLength;
var selEnd = txtarea.selectionEnd; // to mimic IE, assume the caret is the end of the selection
var s1 = (txtarea.value).substring(0, selEnd);
var s2 = (txtarea.value).substring(selEnd, textLength);
txtarea.value = s1 + text + s2;
txtarea.setSelectionRange(selEnd+text.length, selEnd+text.length);
txtarea.focus();
}
else if (txtarea.createTextRange && txtarea.caretPos) {
var caretPos = txtarea.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
txtarea.focus();
} else {
txtarea.value += text;
txtarea.focus();
}
}
Et puis je viens de voir autre chose : quand on est au milieu d'un texte et qu'on clique sur [ i ] (ou n'importe quelle autre balise), la balise s'insère à la toute fin du message. Devinez ce qui se passe avec IE ? J'ai testé et... la balise s'insère aussi à la fin du message
Est-ce qu'il serait possible d'améliorer ça et d'avoir un argument en plus pour Mozilla ?