Home  >  Article  >  Web Front-end  >  Three ways to jump to the page by clicking button tags in HTML

Three ways to jump to the page by clicking button tags in HTML

王林
王林forward
2020-02-27 17:59:435315browse

Three ways to jump to the page by clicking button tags in HTML

Method 1: Use onclick event

<input type="button" value="按钮"
onclick="javascrtpt:window.location.href=&#39;http://www.baidu.com/&#39;" />

or directly use button tag

<button onclick="window.location.href = &#39;https://www.baidu.com/&#39;">百度</button>

(recommended tutorial: html tutorial)

Method 2: Wrap an a tag in the button tag

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

or use

<a href="http://www.baidu.com/"><input type="button" value=&#39;百度&#39;></a>

Method 3: Use JavaScript function

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

More For programming-related content, please pay attention to the Introduction to Programming column on the php Chinese website!

The above is the detailed content of Three ways to jump to the page by clicking button tags in HTML. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:jb51.net. If there is any infringement, please contact admin@php.cn delete