[100爱哈壹分/天] 购买
[100爱哈壹分/天] 购买
[100爱哈壹分/天] 购买
[100爱哈壹分/天] 购买
[100爱哈壹分/天] 购买
[100爱哈壹分/天] 购买
查看: 954|回复: 0

HTML+JS中网页跳转的写法

[复制链接]
已绑定手机

194

主题

425

帖子

5531

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
5531
发表于 2019-10-6 12:57:51 | 显示全部楼层 |阅读模式
1、html中使用meta中跳转,通过meta可以设置跳转时间和页面
<head>    <!--只是刷新不跳转到其他页面 -->    <meta http-equiv="refresh" content="5">    <!--定时转到其他页面 -->    <meta http-equiv="refresh" content="5;url=index.html"> </head>
2、通过javascript中实现跳转
1 // 直接跳转2 window.location.href='index.html';3 // 定时跳转4 setTimeout("javascript:location.href='index.html'", 5000);
3、html跳转上一页的方式
window.history.go(-1);或者window.history.back(-1);
1 <script type="text/javascript">2     var wrong = document.getElementById('btn');3     wrong.onclick = function() { 4     window.history.go(-1);//返回上一页5     window.history.back(-1);//返回上一页6    }7 </script>

在html中写
<a href=”#” onClick=”JavaScript :history.back(1);”>返回上一页</a><a href=”#” onClick=”javascript :history.Go(-1);”>返回上一页</a>

在Js中网页跳转的写法
1、window.location.href
1 window.location.href="http://www.baidu.com"; //在原有窗口打开
2.window.navigate方式跳转
1 window.navigate("http://www.baidu.com");
1 function toBooks() {2     3     //在原有窗口打开4     window.location.href = "http://www.baidu.com";5     //打开新的窗口6     window.open("http://www.baidu.com");7 }


直接跳转加参数
<script language="javascript" type="text/javascript">           window.location.href="login.jsp?backurl="+window.location.href; </script>


参考:https://www.cnblogs.com/jialinG/p/9377427.html
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

让社区更精彩

  • 反馈建议:yjfmlsx@qq.com
  • 工作时间:周一到周五 7:00-18:00
15896165871

关注我们

Copyright   ©2015-2018  2HA Inc.  Powered by©2ha.cn   ( 苏ICP备15059694号 )
快速回复 返回顶部 返回列表