Three ways to jump to a page by clicking a button tag in HTML

Three ways to jump to a page by clicking a button tag in HTML

Method 1: Using the onclick event

<input type="button" value="button"
onclick="javascript:window.location.href='http://www.baidu.com/'" />

Or use the button tag directly

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

Method 2: Add an a tag to the button tag

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

Or use

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

Method 3: Using JavaScript Function

<script>
function jump(){
 window.location.href="http://www.baidu.com/";
}
</script>
<input type="button" value="Baidu" onclick=javascript:jump() />
// Or <input type="button" value="Baidu" onclick="jump()" />
// or <button onclick="jump()">Baidu</button>

Summarize

The above are three methods introduced by the editor to achieve page jump by clicking the button tag in HTML. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

<<:  The most common declaration merge in TS (interface merge)

>>:  Docker deploys Mysql, .Net6, Sqlserver and other containers

Recommend

Demystifying the HTML 5 Working Draft

The World Wide Web Consortium (W3C) has released a...

Modify the maximum number of mysql connections and configuration files in docker

1. Find the mysql image docker ps 2. Enter the mi...

7 Best VSCode Extensions for Vue Developers

Adding the right VS Code extension to Visual Stud...

vue+element custom query component

This article mainly introduces the Vue project. O...

CSS new feature contain controls page redrawing and rearrangement issues

Before introducing the new CSS property contain, ...

Native JavaScript to achieve the effect of carousel

This article shares the specific code for JavaScr...

Sample code for implementing image drawer effect with CSS3

As usual, let’s first post the picture effect: Th...

Linux server quick uninstall and install node environment (easy to get started)

1. Uninstall npm first sudo npm uninstall npm -g ...

In-depth analysis of MySQL execution plans

Preface In the previous interview process, when a...

VUE implements timeline playback component

This article example shares the specific code of ...

Pure HTML+CSS to achieve Element loading effect

This is the effect of the Element UI loading comp...

Detailed explanation of mysql replication tool based on python

Table of contents 1. Introduction Second practice...

Detailed explanation of MySql view trigger stored procedure

view: When a temporary table is used repeatedly, ...

A simple and in-depth study of async and await in JavaScript

Table of contents 1. Introduction 2. Detailed exp...