HTML中button标签点击实现页面跳转的三种方法

2023-12-01 0 386

方法1:使用onclick事件

<input type="button" value="按钮"
onclick="javascrtpt:window.location.href=\’http://www.baidu.com/\’" />

  或者直接使用button标签

<button onclick="window.location.href = \’https://www.baidu.com/\’">百度</button>

方法2:在button标签外套一个a标签

<a href="http://www.baidu.com/">
<button>百度</button>
</a>

  或使用

<a href="http://www.baidu.com/"><input type="button" value=\’百度\’></a>

方法3:使用JavaScript函数

<script>
function jump(){
window.location.href="http://www.baidu.com/";
}
</script>
<input type="button" value="百度" onclick=javascrtpt:jump() />
// 或者<input type="button" value="百度" onclick="jump()" />
// 或者<button onclick="jump()">百度</button>

总结

以上所述是小编给大家介绍的HTML中button标签点击实现页面跳转的三种方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对悠久资源网网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!

收藏 (0) 打赏

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

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

悠久资源 HTML/Xhtml HTML中button标签点击实现页面跳转的三种方法 https://www.u-9.cn/sheji/html/8766.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务