html页面跳转(a标签、meta标签、reload、history.go、history.back等)

本文详细介绍了HTML页面跳转的多种方式,包括a标签的onclick事件、直接使用window.location.href、利用meta标签以及历史记录的go和back方法。通过实例代码展示了如何实现即时跳转和延迟跳转,是前端开发者学习网页导航控制的重要参考资料。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

html页面跳转

1、a标签οnclick

<a href="javascript:void(0);" οnclick="js_method()">foo</a>
<a onclick="window.location.href='www.baidu.com'" href="javascript:void(0);">百度一下</a>

2、a标签直接跳转

<a href="http://baidu.com">百度一下</a>

3、直接跳转

window.location.href='index.html';
<button id="load" οnclick="window.location.reload('/html/index.html')">跳转</button>

4、html跳转上一页的方式

window.history.go(-1);或者window.history.back(-1);
<a href="#" onClick="JavaScript:history.back(-1);">返回上一页</a>
<a href="#" onClick="Javascript:history.go(-1);">返回上一页</a>

5、meta标签跳转

<html>
<head>
<title>Content</title>
<meta http-equiv="refresh" content="0;url=/xxx.do?nav=true">
<!-- 经过一段时间转到另外某个页面 content="0;URL=",这里0表示没有延时,直接跳转到后面的URL;把0改成1,则延时1秒后跳转。 -->
</head>
</html>

参考博客:

a标签href属性与onclick事件
a标签添加onclick事件的几种方式

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值