Código:
function inslink(campo){ var input = document.getElementById(campo); if(typeof document.selection != 'undefined' && document.selection) { var str = document.selection.createRange().text; input.focus(); var my_link = prompt("Enter URL:","http://"); if (my_link != null) { if(str.length==0){ str=my_link; } var sel = document.selection.createRange(); sel.text = "[a href=\"" + my_link + "\"]" + str + "[/a]"; sel.select(); } return; }else if(typeof input.selectionStart != 'undefined'){ var start = input.selectionStart; var end = input.selectionEnd; var insText = input.value.substring(start, end); var my_link = prompt("Enter URL:","http://"); if (my_link != null) { if(insText.length==0){ insText=my_link; } input.value = input.value.substr(0, start) +"[a href=\"" + my_link +"\"]" + insText + "[/a]"+ input.value.substr(end); input.focus(); input.setSelectionRange(start+11+my_link.length+insText.length+4,start+11+my_link.length+insText.length+4); } return; }else{ var my_link = prompt("Ingresar URL:","http://"); var my_text = prompt("Ingresar el texto del link:",""); input.value+=" [a href=\"" + my_link + "\"]" + my_text + "[/a]"; return; } }
Como tengo que cambiar esta linia?Para ponerle el target="_blank"
sel.text = "[a href=\"" + my_link + "\"]" + str + "[/a]";
Muchas gracias!