Premetto che di java capisco praticamente niente:
Ho una textarea (si chiama titolo) dentro è contenuto del testo, devo fare in modo da aggiungere alla parte di testo selezionata dei tag html.
Cosa sbaglio nel replace?

grazie B.


<script type="text/javascript">
<!--
function getgrasstitoloSel()
{
var tit='';
tit=document.theform.titolo.value;

var txt = '';
var foundIn = '';
if (window.getSelection)
{
txt = window.getSelection();
foundIn = '';
foundEnd = '
';

}
else if (document.getSelection)
{
txt = document.getSelection();
foundIn = '';
foundEnd = '
';
}
else if (document.selection)
{
txt = document.selection.createRange().text;
foundIn = '';
foundEnd = '
';

}
else return;
t =foundIn + txt + foundEnd;
t_re=new RegExp(t,"g");
tit2= titolo.replace(txt, t_re);
document.theform.titolo.value = tit2;
}
// -->
</script>