Il Wed, 07 Jun 2006 14:29:02 +0200, simple:maL ha scritto:
Non l'ho testato, ma prova a modificare in qualcosa del genere:
Quote:
function insert_bbcode(v, bbcode){
try {
if (document.selection)
{
v.focus( v.caretPos );
|
v.caretPos = document.selection.createRange().duplicate();
tSel = document.selection.createRange().text;
text = "[" + bbcode + "]" + tSel + "[/" + bbcode + "]";
v.caretPos.text = text;
v.caretPos.moveStart( "character", text.length * -1 );
v.caretPos.select();
Quote:
return;
}
else if ((typeof v.selectionStart) != 'undefined')
{
var bPos = v.selectionStart;
|
var ePos = v.selectionEnd;
var sTop=v.scrollTop;
var myText = (v.value).substring(bPos, ePos);
subst = "[" + bbcode + "]" + myText + "[/" + bbcode + "]";
v.value = v.value.substring(0, bPos) + subst +
v.value.substring(ePos, v.value.length);
v.focus();
var cPos=bPos+(bAdd.length+myText.length+aAdd.length);
v.selectionStart=bPos;
v.selectionEnd=cPos;
v.scrollTop=sTop;
Quote:
return;
}
else {}
}
catch(e){
} |
Se non ho fatto errori ad adattare un mio codice al tuo, dovrebbe
funzionare :-)
'bye