gpt4 book ai didi

javascript - window.location 不会重定向到另一个 html 页面

转载 作者:行者123 更新时间:2023-12-03 04:18:59 24 4
gpt4 key购买 nike

我正在使用此登录页面:http://csshtmljs.com/bootstrap-snippets.php?code-snippets=904&q=Bootstrap+snippet+DeyNote+like+login 。我为登录和注册按钮编写了 javascript 函数,这些函数应该重定向到适当的页面,但它不起作用。这是登录.html:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- This file has been downloaded from bootdey.com @bootdey on twitter -->
<!-- All snippets are MIT license http://bootdey.com/license -->
<!--
The codes are free, but we require linking to our web site.
Why to Link?
A true story: one girl didn't set a link and had no decent date for two years, and another guy set a link and got a top ranking in Google!
Where to Put the Link?
home, about, credits... or in a good page that you want
THANK YOU MY FRIEND!
-->
<title>DeyNote like login - Bootdey.com</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">
<style type="text/css">
body{
margin-top:20px;
color:#fff;
}

.login-page {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
overflow: auto;
background: #3ca2e0;
text-align: center;
color: #fff;
padding: 3em;
}

.user-avatar {
width: 125px;
height: 125px;
}

.login-page h1 {
font-weight: 300;
}

.login-page .form-content {
padding: 40px 0;
}

.login-page .form-content .input-underline {
background: 0 0;
border: none;
box-shadow: none;
border-bottom: 2px solid rgba(255,255,255,.4);
color: #FFF;
border-radius: 0;
}
.login-page .form-content .input-underline:focus {
border-bottom: 2px solid #fff;
}

.input-lg {
height: 46px;
padding: 10px 16px;
font-size: 18px;
line-height: 1.3333333;
border-radius: 0;
}

.btn-info{
border-radius: 50px;
box-shadow: 0 0 0 2px rgba(255,255,255,.8)inset;
color: rgba(255,255,255,.8);
background: 0 0;
border-color: transparent;
font-weight: 400;
}

input[type='text']::-webkit-input-placeholder, input[type='password']::-webkit-input-placeholder {
color: #fff;
}
input[type='text']:-moz-placeholder, input[type='password']:-moz-placeholder {
color: #fff;
}
input[type='text']::-moz-placeholder, input[type='password']::-moz-placeholder {
color: #fff;
}
input[type='text']:-ms-input-placeholder, input[type='password']:-ms-input-placeholder {
color: #fff;
}
</style>
</head>
<body>
<div class="container bootstrap snippet">
<div class="row login-page">
<div class="col-md-4 col-lg-4 col-md-offset-4 col-lg-offset-4">
<img src="http://ani-theme.strapui.com/images/flat-avatar.png" class="user-avatar">
<h1>Bootdey.com</h1>
<form role="form" class="ng-pristine ng-valid">
<div class="form-content">
<div class="form-group">
<input type="text" class="form-control input-underline input-lg" placeholder="Email">
</div>
<div class="form-group">
<input type="password" class="form-control input-underline input-lg" placeholder="Password">
</div>
</div>
<button class="btn btn-info btn-lg" onclick="login()">
Log in
</button> &nbsp;
<button type="submit" class="btn btn-info btn-lg">Register</button>
</form>
</div>
</div>
</div>

<script src="http://netdna.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script type="text/javascript" src="login.js">

</script>
</body>
</html>

登录.js:

function login(){
window.location="createGame.html";
}

没有错误,但页面没有被替换。我会感谢你的帮助。谢谢

最佳答案

// similar behavior as an HTTP redirect

window.location.replace("http://stackoverflow.com");

// similar behavior as clicking on a link

window.location.href = "http://stackoverflow.com";

关于javascript - window.location 不会重定向到另一个 html 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44027730/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com