[英]Why can't my javascript redirect the following code, I've tried multiple solution that i found in StackOverFlow
I have tried multiple of things making the code to redirect, my teacher told me that I need to use method POST, while the following code is the working one which the method get, if I change the method to POST it cannot redirect.我尝试了多种使代码重定向的方法,我的老师告诉我需要使用方法 POST,而以下代码是该方法获取的有效代码,如果我将方法更改为 POST,则无法重定向。 I tried using the location.href inside my code, it doesn't seem to work at all.我尝试在我的代码中使用 location.href,它似乎根本不起作用。 I even tried putting the return false in my javascript.我什至尝试将 return false 放在我的 javascript 中。 May I know how can I fix these issues?我可以知道如何解决这些问题吗?
The following are my code for my form以下是我的表单代码
<form action="/Membership/member-profilepage/member_home.html">
<div class="row">
<div class="col-1">
<input type="text" name="username" placeholder="Username" required>
<input type="password" name="password" placeholder="Password" required>
<input type="checkbox" id="rmbpw" name="rmbpw" value="rmbpw">
<label for="rmbpw" id="rmbpw" name="rmbpw"> RememberMe</label>
<input type="submit" value="Login" onclick="login()">
</div>
<script src="login.js"></script>
</div>
</form>
This will be the code for my javascript这将是我的 javascript 的代码
function login(){
alert("Login Successfully!");
}
Oh, Guys, I figure out an answer after doing a couple more research and trying a few more things.哦,伙计们,在做了更多的研究并尝试了更多的事情之后,我找到了答案。 I cannot use input type="submit".我不能使用输入类型=“提交”。 Hence, I need to use input type="button" to do the redirection.因此,我需要使用 input type="button" 来进行重定向。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.