前端-html 点击 跳转页面

本文介绍了HTML中实现页面跳转的四种常见方法:通过button标签的onclick属性、使用JavaScript函数、利用a标签作为超链接以及表单action提交等方式实现。

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

html 点击 跳转页面

第一种:

在 button 标签加上 onclick 属性,使用 window.location.href='url' 进行跳转
<input type="button" name="register" value="注册" onclick="window.location.href='register.jsp'"/>
<input type="button" value="按钮" onclick="javascript:window.location.href='https://blog.youkuaiyun.com/qq_42124842'"/>

第二种:

使用函数进行跳转,在 js 中还是比较常用的
<script>
    function jump(){
        window.location.href="https://blog.youkuaiyun.com/qq_42124842";
    };
</script>
 
<input type="button" value="我是一个按钮" οnclick=javascrtpt:jump()/>

第三种:

使用 a 标签超链接进行嵌套
<a href="https://blog.youkuaiyun.com/qq_42124842">
    <button>跳转</button>
</a>

第四种:

表单 action 定向提交跳转
<form action="xx.html" method="get">
    <input type="button" value="按钮">
</from>

泡泡:

网站前端跳转方式 不像微信小程序里面 wx.navigateTo, wx.redirectTo 来的那么直接,不过也还好。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值