2017-04-11 2 views
0

Dies ist mein Code, und ich möchte auf eine andere Site umleiten, wenn ich auf Submit klicke, und ich kann nicht finden, wo der Fehler ist. Es ist ein einfacher Code und ich weiß, dass es etwas "hässlich" zu sehen ist, aber ich teste es nur.HTML kann nicht umgeleitet werden

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

+0

Warum nicht einfach setzen Sie den '' form' der action' Parameter an die URL? –

+0

Sie müssen Wert an andere URL senden oder einfach umleiten? –

+0

'window.location.replace (" https://www.outlook.com ");" Wie wäre es damit? –

Antwort

1

Sie sollten diese in der Lage sein, zu erreichen mit dem folgenden Code:

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

Setzen Sie einfach die Formularaktion und die Formulardaten werden an die neue URL gesendet.

+0

** Es hat funktioniert. TY! ** –

+0

Kein Problem, bitte als akzeptiert markieren, wenn Sie @BernatPedrolVozmediano :) –

0

mir beantworten:

Um zu vermeiden, Fehler 405, ändern

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

für

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