JS跳转页面参考代码

JS跳转页面参考代码 

可以将系统的api二次封闭提高易用性



第一种: 
<script language="javascript" type="text/javascript"> 
window.location.href="login.jsp?backurl="+window.location.href; 
</script> 
第二种: 
<script language="javascript"> 
alert("返回"); 
window.history.back(-1); 
</script> 
第三种: 
<script language="javascript"> 
window.navigate("top.jsp"); 
</script> 
第四种: 
<script language="JavaScript"> 
self.location='top.htm'; 
</script> 
第五种: 
<script language="javascript"> 
alert("非法访问!"); 
top.location='xx.jsp'; 
</script> 

转载于:https://www.cnblogs.com/lguow/articles/9222307.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
软件登录及跳转页面开发的代码需要根据具体的开发语言和框架来进行编写,下面以常见的Web开发为例: 1. 登录页面代码(HTML、CSS、JavaScript): ```html <!DOCTYPE html> <html> <head> <title>Login</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <div class="login-container"> <h1>Login</h1> <form> <label for="username">Username:</label> <input type="text" id="username" name="username"> <label for="password">Password:</label> <input type="password" id="password" name="password"> <input type="submit" value="Login" onclick="login()"> </form> </div> <script src="script.js"></script> </body> </html> ``` ```css .login-container { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; } form { display: flex; flex-direction: column; align-items: center; justify-content: center; margin-top: 20px; } label { margin-top: 10px; } input[type="text"], input[type="password"] { width: 200px; height: 30px; margin-top: 5px; margin-bottom: 10px; text-align: center; border-radius: 5px; } input[type="submit"] { width: 100px; height: 30px; margin-top: 10px; background-color: #4CAF50; color: white; border: none; border-radius: 5px; cursor: pointer; } input[type="submit"]:hover { background-color: #3e8e41; } ``` ```javascript function login() { event.preventDefault(); // 阻止表单的默认提交行为 var username = document.getElementById("username").value; var password = document.getElementById("password").value; // 发送登录请求,验证用户名和密码 // 如果验证通过,跳转到首页 // 如果验证不通过,提示错误信息 if (username === "admin" && password === "123456") { window.location.href = "home.html"; } else { alert("Invalid username or password!"); } } ``` 2. 首页代码(HTML、CSS): ```html <!DOCTYPE html> <html> <head> <title>Home</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <div class="home-container"> <h1>Welcome to the home page!</h1> <p>This is the content of the home page.</p> <button onclick="logout()">Logout</button> </div> <script src="script.js"></script> </body> </html> ``` ```css .home-container { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; } button { margin-top: 20px; background-color: #4CAF50; color: white; border: none; border-radius: 5px; cursor: pointer; } button:hover { background-color: #3e8e41; } ``` ```javascript function logout() { // 发送注销请求,清空登录状态 // 跳转到登录页面 window.location.href = "login.html"; } ``` 以上代码仅供参考,实际开发中需要根据具体要求进行调整和完善。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值