美文网首页
HTML+JS中网页跳转的写法

HTML+JS中网页跳转的写法

作者: elileo | 来源:发表于2019-06-02 15:54 被阅读0次

1、html中使用meta中跳转,通过meta可以设置跳转时间和页面

<head>
    <!--只是刷新不跳转到其他页面 -->
    <meta http-equiv="refresh" content="5">
    <!--定时转到其他页面 -->
    <meta http-equiv="refresh" content="5;url=index.html"> 
</head>

2、通过javascript中实现跳转

// 直接跳转
window.location.href='index.html';
// 定时跳转
setTimeout("javascript:location.href='index.html'", 5000);

3、html跳转上一页的方式

<script type="text/javascript">
    var wrong = document.getElementById('btn');
    wrong.onclick = function() { 
    window.history.go(-1);//返回上一页
    window.history.back(-1);//返回上一页
   }
</script>

在html中写

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

在Js中网页跳转的写法

1、window.location.href

window.location.href="http://www.baidu.com"; //在原有窗口打开

2.window.navigate方式跳转

window.navigate("http://www.baidu.com");

function toBooks() {
    
    //在原有窗口打开
    window.location.href = "http://www.baidu.com";
    //打开新的窗口
    window.open("http://www.baidu.com");
}

直接跳转加参数

<script language="javascript" type="text/javascript">
           window.location.href="login.jsp?backurl="+window.location.href; 
</script>

相关文章

  • HTML+JS中网页跳转的写法

    1、html中使用meta中跳转,通过meta可以设置跳转时间和页面 2、通过javascript中实现跳转 3、...

  • 跳转网页的方法介绍

    1.为什么要跳转网页?点击UICollectionView的cell我们发现跳转到了网页 2.在以后开发中,怎么判...

  • vue页面跳转

    一、在template中的常见写法: 二、在js中设置跳转(在方法中跳转界面并传参,两种方式:params 与 q...

  • 关于前端跳转到原生页面

    网页或者是移动app跳转都是内部跳转,即网页跳转网页或者是原生页面之间的跳转。之所以有前端和原生之间的交互,是因为...

  • 路由的query传参

    使用 跳转路由并携带query参数,to的字符串写法: 跳转路由并携带query参数,to的对象写法: 接收 除了...

  • Kotlin 跳转Activity

    Activity之间的跳转,Kotlin写法:

  • python 网络爬虫第三章-爬取维基百科(2)

    3.1.2 随机打开网页中的文章链接 目标:随机漫步从一个网页随机跳转到该网页中的链接,如此循环。示例代码如下: ...

  • 网页跳转

  • 网页的跳转

    跳转web界面有4种方式1、 直接跳转Safari浏览器:有刷新、后退、进度条等;2、 UIWebView:没有控...

  • js截取url字符串

    1.网页跳转 2.网页参数获取

网友评论

      本文标题:HTML+JS中网页跳转的写法

      本文链接:https://www.haomeiwen.com/subject/homxxctx.html