html/JavaScript怎么跳转页面


本文摘自PHP中文网,作者青灯夜游,侵删。

跳转页面的方法:1、html中可以利用meta标签进行跳转,语法“”;2、javascript中可以利用location对象的href属性进行跳转,语法“window.location.href=页面地址”。

本教程操作环境:windows7系统、javascript1.8.5版、Dell G3电脑。

html/JavaScript实现页面跳转

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

1

2

3

4

5

6

<head>

    <!--只是刷新不跳转到其他页面 -->

    <meta http-equiv="refresh" content="5">

    <!--定时转到其他页面 -->

    <meta http-equiv="refresh" content="5;url=index.html">

</head>

2、通过javascript中实现跳转

1

2

3

4

1 // 直接跳转

2 window.location.href='index.html';

3 // 定时跳转

4 setTimeout("javascript:location.href='index.html'", 5000);

html跳转上一页的方式

window.history.go(-1);或者window.history.back(-1);

1

2

3

4

5

6

7

<script type="text/javascript">

    var wrong = document.getElementById('btn');

    wrong.onclick = function() {

    window.history.go(-1);//返回上一页

     window.history.back(-1);//返回上一页

   }

</script>

在html中写

1

2

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

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

【推荐学习:javascript高级教程

以上就是html/JavaScript怎么跳转页面的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

javascript警告是什么意思

Html怎么给文字加粗

怎么在javascript中进行多行注释

javascript如何检查一个对象是否为空(代码示例)

javascript继承的6种方法是什么

js中eval函数有什么用

Html页面如何实现3秒之后自动跳转

javascript dom对象怎么转字符串

Html的 <nav> 标签

用canvas实现简单的下雪效果(附代码)

更多相关阅读请进入《Html》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...