HTML+JS中网页跳转的写法

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值