Non mi funziona!
codice:
function tag (codice) {
var tarea = document.nuovo.scritto;
if(codice=='img'){
var imgurl=prompt('".str_replace("'","\'",$arr_lang[456])."','http://www.tuo_sito.it/immagine.jpg');
if(imgurl!=null && imgurl!=''){
tarea.value+='[img src='+imgurl+']';
}
}else{
if(document.selection && document.selection.createRange()){
tarea.focus();
var selez=document.selection;
var creorang=selez.createRange();
creorang.collapse;
if(creorang.text==''){
switch(codice) {
case 'b':creorang.text+=''; break;
case 'i':creorang.text+=''; break;
case 'u':creorang.text+=''; break;
case 's':creorang.text+='[strike][/strike]'; break;
}
}else if(tarea.selectionEnd){
var lung=tarea.textLength;
var from=tarea.selectionStart;
var to=tarea.selectionEnd;
switch(codice) {
case 'b':tarea.value=tarea.value.substring(0,from)+'[b]'+tarea.value.substring(to,lung); break;
case 'i':testosel=''+creorang.text+''; break;
case 'u':testosel=''+creorang.text+''; break;
case 's':testosel='[strike]'+creorang.text+'[/strike]'; break;
}
//creorang.text=testosel;
}else{
tarea.value+='codice';
}
}
tarea.focus();
}
}
ho anche provato con:
codice:
function tag (codice) {
var tarea = document.nuovo.scritto;
if(codice=='img'){
var imgurl=prompt('".str_replace("'","\'",$arr_lang[456])."','http://www.tuo_sito.it/immagine.jpg');
if(imgurl!=null && imgurl!=''){
tarea.value+='[img src='+imgurl+']';
}
}else{
if(document.selection && document.selection.createRange()){
tarea.focus();
var selez=document.selection;
var creorang=selez.createRange();
creorang.collapse;
if(creorang.text==''){
switch(codice) {
case 'b':creorang.text+=''; break;
case 'i':creorang.text+=''; break;
case 'u':creorang.text+=''; break;
case 's':creorang.text+='[strike][/strike]'; break;
}
}else if(tarea.selectionEnd){
var lung=tarea.textLength;
var from=tarea.selectionStart;
var to=tarea.selectionEnd;
switch(codice) {
case 'b':testosel=tarea.value.substring(0,from)+'[b]'+tarea.value.substring(to,lung); break;
case 'i':testosel=''+creorang.text+''; break;
case 'u':testosel=''+creorang.text+''; break;
case 's':testosel='[strike]'+creorang.text+'[/strike]'; break;
}
creorang.text=testosel;
}else{
tarea.value+='codice';
}
}
tarea.focus();
}
}
Ma ovviamente nulla.
Non c'è proprio un modo per adattare quel js a quello che mi serve?
Ciaooooooooooooooooooooo!!!!!!!!!