Ver Mensaje Individual
  #2 (permalink)  
Antiguo 24/05/2007, 14:03
Avatar de Adler
Adler
Colaborador
 
Fecha de Ingreso: diciembre-2006
Mensajes: 4.671
Antigüedad: 18 años, 2 meses
Puntos: 126
Re: Boton ingresar enlace (como en el foro)

Código:
// Insertar vinculo 
function vinculo(open,close) { 	
var txt = document.FORM.CAMPO; 	// Edita esto con los datos correctos
var url = null; 	
var url= prompt("Ingrese una dirección","http://");  	
seleccion = document.selection.createRange().text;
        if (!seleccion) {
        alert("Has de selecionar un texto")
        txt.focus();
        return;
        }
        if (seleccion) {
if ((url==null) || (url== "undefined") || (url=="") || (url==' ')) { 			
alert("No has introducido una dirección válida") 			
txt.focus(); 			
return; 			
} 			
document.selection.createRange().text = open +url+"]" + seleccion + close; 			txt.focus(); 			
return; 			
}  		
}
Se ejecuta con

Código:
<input type="button name="url" id="url" value="URL" OnClick="vinculo('[url=','[/url]');" />
Suerte