Salve, ho usato questa funzione per posizionare un tag davanti e uno dietro al testo selezionato:
Ciò che non riesco a fare è posizionare il puntatore tra i due tag inseriti!Codice:function textarea_wrap_text(obj, str_pre, str_post) { var obj = document.getElementById(obj); if (document.selection) { // Internet Explorer obj.focus(); sel = document.selection.createRange(); sel.text = str_pre + sel.text + str_post; obj.focus(); } else if (obj.selectionStart || obj.selectionStart == '0') { // Others var pos_1 = obj.selectionStart; var pos_2 = obj.selectionEnd; obj.value = obj.value.substring(0, pos_1) + str_pre + obj.value.substring(pos_1, pos_2) + str_post + obj.value.substring(pos_2, obj.value.length); } else { // Fallback obj.value += str_pre + str_post; } }
Mettendoci un obj.focus(); me lo posiziona alla fine.
Qualcuno riesce ad aiutarmi?

LinkBack URL
About LinkBacks
