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

html中通过点击button标签实现页面跳转的三种方法,第1张

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

方法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>

(推荐教程:html教程)

方法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>

更多编程相关内容,请关注php中文网编程入门栏目!

以上就是html中通过点击button标签实现页面跳转的三种方法的详细内容,

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/694532.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-22
下一篇 2022-04-22

发表评论

登录后才能评论

评论列表(0条)

保存