我摆弄着假装“登录屏幕”,但在重定向页面时遇到麻烦。Javascript:重定向页面onclick
我已经尝试了几个我在网站上发现的不同建议,但到目前为止没有任何工作。
我真的认为我只是做错了。
有什么建议吗?
HTML
<div class="title"><h1>Webby Site</h1></div>
<div class="login-page">
<div class="form">
<form class="login-form">
<input id="User" type="text" placeholder="username"/>
<input id="PWord" type="password" placeholder="password"/>
<button class="button">Login</button>
<p class="message">Not registered? <a>Create an account</a></p>
</form>
</div>
</div>
JS我已经试过(在同一地区为document.location.href
)
$(document).ready(function(){
$('.button').click(function(){
if ($('input#User').val() === "1" && $('input#PWord').val() === "1"){
document.location.href = "www.yoursite.com";
} else {
alert('Incorrect Account Details');
}
});
});
代码
document.location
window.location
window.location.href
location.href
您能在JSFiddle重现这个问题吗? –
@YeldarKurmangaliyev不幸的是,虽然它在Chrome中工作正常,但它在JSFiddle中完全不起作用。我得到“{”错误“:”请使用POST请求“}”。但是,无论如何,如果它有帮助,我可以创造一个吗? – Asteria