![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
24/05/2007, 14:03
|
![Avatar de Adler](http://static.forosdelweb.com/customavatars/avatar163014_6.gif) | Colaborador | | Fecha de Ingreso: diciembre-2006
Mensajes: 4.671
Antigüedad: 18 años, 1 mes 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 |