html中通过点击button标签实现页面跳转的三种方法
生活随笔
收集整理的這篇文章主要介紹了
html中通过点击button标签实现页面跳转的三种方法
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
方法1:使用onclick事件
<input type="button" value="按鈕"onclick="javascrtpt:window.location.href='http://www.baidu.com/'" />或者直接使用button標(biāo)簽
<button onclick="window.location.href = 'https://www.baidu.com/'">百度</button>方法2:在button標(biāo)簽外套一個(gè)a標(biāo)簽
<a href="http://www.baidu.com/"><button>百度</button></a>或使用
<a href="http://www.baidu.com/"><input type="button" value='百度'></a>方法3:使用JavaScript函數(shù)
<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>總結(jié)
以上是生活随笔為你收集整理的html中通过点击button标签实现页面跳转的三种方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 贵州省谷歌地球高程DEM等高线下载
- 下一篇: 软件工程毕设项目 - 基于SSM的毕业设