这是我的代码..我必须整合那部分以及如何继续......
function validate() {
var un = document.loginscreen.uname.value;
var pw = document.loginscreen.psw.value;
var username = "John_Smith";
var password = "syntel123$";
if ((un == username) && (pw == password)) {
window.location = "file:///C:/Users/KS5034674/Desktop/Gagile/WebContent/homescreen.html";
return true;
} else {
console.log("login Failed");
}
}

form {
width: 100%;
border: 0px solid #f1f1f1;
}
.container {
padding: 16px;
text-align: center;
}
input[type=text],
input[type=password] {
width: 100%;
height: 40%;
padding: 15px 10px 6px 9px;
margin-: 80px;
display: inline-tablecolumngroup;
border: 1px solid #ccc;
box-sizing: border-box;
}
#input_container {
position: absolute;
padding: 0 0 0 0px;
margin: 0 20px;
direction: ltr;
width: 80%;
}
#input {
height: 40px;
margin: 0;
width: 80%;
text-align: center;
}
#input_img {
position: absolute;
bottom: 10px;
left: 50px;
width: 20px;
height: 20px;
}
#input_container1 {
position: absolute;
padding: 0 0 0 0px;
margin: 0 20px;
direction: ltr;
width: 80%;
}
#input1 {
height: 40px;
margin: 0;
width: 80%;
text-align: center;
}
#input_img1 {
position: absolute;
bottom: 10px;
left: 50px;
width: 20px;
height: 20px;
}
button {
background-color: #0052A6;
color: white;
border: none;
cursor: pointer;
width: 70%;
height: 40px;
}
.imgcontainer {
text-align: center;
margin: 24px 0 12px 0;
}
img.syntel {
width: 40%;
border-radius: 0%;
}
img.agileimg {
width: 30%;
border-radius: 40%;
}
img.abc {
padding: 0 0px 0px 0px;
width: 20px;
height: 20px;
}
span.psw {
float: right;
padding-top: 16px;
}
/* Change styles for span and cancel button on extra small screens */
@media screen and (max-width: 300px) {
span.psw {
display: block;
float: none;
}
.cancelbtn {
width: 100%;
}
}

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<body>
<form name="loginscreen" onsubmit="return validate()" action="file:///C:/Users/KS5034674/Desktop/Gagile/WebContent/homescreen.html" method="post" >
<div class="imgcontainer">
<br> <br><br>
<img src=" C:\Users\KS5034674\Downloads\Gagile\project images\syntel.png" alt="syntel" class="syntel">
<br><br><br> <br>
<img src=" C:\Users\KS5034674\Downloads\Gagile\project images\agileimg.png" alt="agileimg" class="agileimg">
</div>
<br><br><br>
<div id="placeholder" align="center"></div>
<div class="container">
<div id="input_container">
<input type="text" id="input" placeholder="Username" name="uname" required style="border-radius:7px;">
<img src=" C:\Users\KS5034674\Downloads\Gagile\project images\username.png" id="input_img">
</div><br><br><br>
<div id="input_container1">
<input type="password" id="input1" placeholder="Password" name="psw" required style="border-radius:7px;">
<img src=" C:\Users\KS5034674\Downloads\Gagile\project images\password.png" id="input_img1">
</div>
</div>
<br><br>                 
<img src=" C:\Users\KS5034674\Downloads\Gagile\project images\check.png" class="abc">  <small>Remember me</small>
<br><br><br>
<div class="container">
<button type="submit" >Login</button><br><br><br><br><br><br>
</head>
</form>
</body>
</html>
&#13;
答案 0 :(得分:0)
您好,请使用此代码,这是在您点击网址后获取json中的数据 这是jsonv.json文件,然后是validate()函数
var a = document.getElementById('a2')
html2canvas(document.getElementById('a1'), {
onrendered: function(canvas) {
var img = canvas.toDataURL("image/jpeg");
window.open(img);
}
}
答案 1 :(得分:0)
如果您已将数据存储在任何网址中,那么您可以发布ajax网址:''如果您想在打开新网页相同标签后登录成功,请使用_self
function validate() {
var jsdata;
$.ajax({
type: "POST",
url:"http://172.25.183.183:8080/JIRAservice/rest/login/",
dataType: "json",
data: JSON.stringify({
user_name: $("#input").val(),
password: $("#input1").val()
}),
success: function(response) {
jsdata=response;
var un = document.loginscreen.uname.value;
var pw = document.loginscreen.psw.value;
if ((un == jsdata.user_name) && (pw == jsdata.password)) {
var myWindow = window.open("file:///C:/Users/KS5034674/Desktop/Gagile/WebContent/homescreen.html", "_self");
return true;
} else {
console.log("login Failed");
}
},
error: function(response) {
console.log(response);
}
});
}