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 5设计原则介绍

html css怎么隐藏滚动条

怎样解决在html中竖列文字竖列显示不全的问题

html悬停时如何改变链接a样式

添加背景音乐的html标签是什么

html是什么?html网页的简单设计方法介绍

html span标签是什么意思?span标签的作用详解

html怎么加入js

html简单介绍

html下拉框怎么做

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




打赏

取消

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

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

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

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

评论

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