Voglio modificare uno script che ho in questo modo. Attualmente ho una funzione che mi chiede due variabili (una è url l'altra è il nome che compare). Purtroppo però non si può agire su un tsto selezionato, ma lo pone sempre in fondo.
codice:
function addTag2(tagName, f) {
var elem=f.textbody;
var what=window.prompt("Inserire la pagina da linkare con INCLUSO http:// ");
var what2=window.prompt("Inserire il nome da visualizzare ");
if(what!="undefined") elem.value+=" <"+tagName+" href=\""+what+"\">"+what2+"</"+tagName+">";
}
Vorrei appunto modificarlo. Ho altri script che in alcune parti agiscono sulle selezioni, ma non so comporli, ecco un esempio:
codice:
var txtarea = document.post.textbody;
txtarea.focus();
theSelection = false;
theSelection = document.selection.createRange().text; // Get text selection
if (theSelection) {
// Add tags around selection
document.selection.createRange().text = bbtags[bbnumber] + theSelection + bbtags[bbnumber+1];
txtarea.focus();
theSelection = '';
return;
}
storeCaret(txtarea);