Home > Web Front-end > HTML Tutorial > 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

王林
Release: 2020-02-27 17:59:43
forward
5349 people have browsed it

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;" />
Copy after login

or directly use button tag

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

(recommended tutorial: html tutorial)

Method 2: Wrap an a tag in the button tag

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

or use

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

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>
Copy after login

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!

Related labels:
source:jb51.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template