0

This is my code, and I want to redirect to another site when clicking Submit, and I can't find where is the error. It's a simple code and I know it's a little "ugly" to see, but I'm only testing.

<!DOCTYPE html>
<html>
 <head>
   <meta charset="UTF-8">
   <link href="paginaweb.css" rel="stylesheet" type="text/css">
   <script type="text/javascript">
    function redirect(){
      window.location.href("https://www.outlook.com");
      return(false);
    }
    </script>
 </head>
 
  <body class="container">
   <div class="image"> </div>​
    <div>
     <style>
      input[type=text] {
          width: 100%;
          padding: 12px 20px;
          margin: 8px 0;
          box-sizing: border-box;
      }
     </style>
     <label for="email">
     <p class="fuente">Introduce tu email para conectarte a Internet.</p></label>
     <form onsubmit="redirect()">
      <input type="email" placeholder="Your email...">
     <input type="submit" id="submit" value="Submit">
     </form>
    </div>
   </body>
</html>

3 Answers3

1

You should be able to achieve this with the following code:

<form method="post" action="newurl.com">
    <input name="email" type="email" placeholder="Your email...">
    <input type="submit" id="submit" value="Submit">
</form>

Just set the form action and the form data will be sent to the new url.

Andy Holmes
  • 7,817
  • 10
  • 50
  • 83
0

Usage of window.location.href
window.location.href = "http://example.com";
Source: https://developer.mozilla.org/es/docs/Web/API/Window/location

Roy Bogado
  • 4,299
  • 1
  • 15
  • 31
0

Answering to myself:

To avoid error 405, change

<form method="post" action="newurl.com"> 

for

<form method="get" action="newurl.com">