js登陆自动计算秒数跳转的代码

发布时间:2019-09-21编辑:脚本学堂
分享一例js代码,在登陆成功后,自动计算秒数,原来开始跳转,有需要的朋友参考下。

本节内容:
一例登陆成功后自动查秒跳转的代码。
 
1,登录页面 login.html
 

复制代码 代码示例:

<script language="javascript" type="text/javascript">
function $(id){
return document.getElementById(id);
}

function checkUser(){
if($("u1").value == "hello" && $("p1").value == "123"){
return true;
}else{
return false;
}
}
</script>
<form action = "ok.html">
<div style = "width:300px;height:200px;border:1px solid red;background-color:pink">
<p/>
U:<input id = "u1" type = "text" value = "" /> <br><br>
P:<input id = "p1" type = "text" value = "" /> <br><br>
<input type = "submit" onclick = "return checkUser()" value = "登陆" style = "margin-left:20px"/>
</div>
</form>

2,跳转页面 ok.html
 

复制代码 代码示例:
<script language = "javascript" type = "text/javascript">
setTimeout("javascript:clearInterval(mytime);window.open('manage.html')",5000);
function changeSec(){
document.getElementById("myspan").innerText =
parseInt(document.getElementById("myspan").innerText) - 1;
}
var mytime = setInterval("changeSec()",1000);
</script>
登陆成功 <span id = "myspan">5</span> 秒钟后自动跳转...

3,manage.html
welcome

演示截图:
登陆后跳转