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


本文摘自PHP中文网,作者V,侵删。

方法1:使用onclick事件

1

2

<input type="button" value="按钮"

onclick="javascrtpt:window.location.href='http://www.baidu.com/'" />

或者直接使用button标签

1

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

(推荐教程:html教程)

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

1

2

3

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

    <button>百度</button>

</a>

或使用

1

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

方法3:使用JavaScript函数

1

2

3

4

5

6

7

8

<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标签实现页面跳转的三种方法的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

在html里的hr水平线应该如何使用

什么软件可以编写html代码

怎么在html页面写css样式表

html select标签怎么用

如何在微信小程序中显示html格式内容(图文教程)

springboot如何返回html和jsp

js的dom是什么?

如何解决html form乱码问题

html form标签怎么用

html的语法详解

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




打赏

取消

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

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

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

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

评论

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