Ver Mensaje Individual
  #2 (permalink)  
Antiguo 30/01/2015, 12:29
bathorz
 
Fecha de Ingreso: agosto-2013
Mensajes: 150
Antigüedad: 10 años, 8 meses
Puntos: 29
Respuesta: Como modificar link con Javascript

Prueba eliminar 7 caracteres (http://) u once (http://www.), como convenga.
Código HTML:
Ver original
  1. <!DOCTYPE html>
  2.    <head>
  3.       <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4.       <title>js</title>
  5.       <style type="text/css">
  6.          input{width: 250px;}
  7.       </style>
  8.       <script type="text/javascript">
  9.          window.onload = function () {
  10.  
  11.             var test = document.getElementById('test');
  12.             var boton = document.getElementById('boton');
  13.  
  14.             boton.addEventListener('click', function (e) {
  15.                e.preventDefault();
  16.                var url = document.getElementById('url').value;
  17.                var string = url.substring(7); // eliminar http://
  18.                test.innerHTML = string;
  19.             });
  20.  
  21.          };
  22.       </script>
  23.    </head>
  24.    <body>
  25.       <form id="form1">
  26.          <input type="text" id="url" value="http://www.forosdelweb.com/f13/" />
  27.          <button id="boton">enviar</button>
  28.       </form>
  29.       <div id="test">test</div>
  30.    </body></html>