Pogledao sam skriptu za citiranje, i sama funkcija addtag nije baš najsrećnije napisana. Da bi se ispravilo dovoljno je dodati:
es.js
Code:
...
else if(txt.selectionStart || txt.selectionStart == '0') {
// start dodatka
oldSelectionStart=txt.selectionStart;
oldSelectionEnd=txt.selectionEnd;
// end dodatka
if(number == 0) txt.value = (txt.value).substring(0, txt.selectionStart) + tag + (txt.value).substring(txt.selectionEnd, txt.textLength);
if(number == 1) txt.value = (txt.value).substring(0, txt.selectionStart) + "["+tag+"]" + (txt.value).substring(txt.selectionEnd, txt.textLength);
if(number == 2) txt.value = (txt.value).substring(0, txt.selectionStart) + "["+tag+"]" + (txt.value).substring(txt.selectionStart, txt.selectionEnd) + "[/"+tag+"]" + (txt.value).substring(txt.selectionEnd, txt.textLength);
// start dodatka
if(number == 0) txt.selectionStart=oldSelectionStart+tag.length;
if(number == 1) txt.selectionStart=oldSelectionStart+tag.length+2;
if(number == 2) txt.selectionStart=oldSelectionStart+tag.length*2+5+oldSelectionEnd-oldSelectionStart;
txt.selectionEnd=txt.selectionStart;
// end dodatka
} else {
...
Problem je u tome što se kod webkit browsera selection ne menja nakon dodavanja teksta, a kod ff-a se selection pomeri na kraj teksta.
Sa ovom izmenom se selekcija pomera ručno nakon ubacivanja.
Sad ja znam zašto sam vam ovo ispričao, ovo će sigurno nekome koristiti....