简体   繁体   English

为什么我的 javascript 不能重定向以下代码,我尝试了多种解决方案,我在 StackOverFlow 中找到了

[英]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">&nbsp;&nbsp;&nbsp;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.

相关问题 为什么不能以短代码将Web Clip图标添加到我的Web应用程序中。 我已经尝试了一切? - Why can't I add a web clip icon to my webapp in dashcode. I've tried everything? 我试过在 JavaScript 中设置我的 Canvas 但它不起作用 - I've tried setting up my Canvas in JavaScript and it isn't working Javascript/Jquery:代码不重复我尝试过的任何循环 - Javascript/Jquery: code not repeating with any loop I've tried 我已经盯着我的代码几个小时了,找不到它出了什么问题。 -Javascript - I've been staring at my code for hours and can't find whats wrong with it. - Javascript Javascript计算排列-当我不复制数组时,为什么我的代码返回不需要的解决方案? - Javascript computing permutations - why is my code returning unwanted solution when I don't make a copy of the array? 为什么我无法在JavaScript代码中获得输入值 - Why I can't get input value in my javascript code 在Javascript中,为什么我无法绘制我的对象的多个实例? - In Javascript, why I can't draw multiple instance of my object? 如何将以下常规 JavaScript 代码转换为 VueJS? - How can I convert my following regular JavaScript code to VueJS? 我已经编写了自己的javascript bencode库,但仍然无法生成种子信息哈希? - I've written my own javascript bencode library and I still can't generate torrent info hashes? 我已经尝试了createTextNode的每个换行符,但是我不能 - I've tried every line break for createTextNode but I can't make one
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM