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

How to deploy ElasticSearch in Docker

1. What is ElasticSearch? Elasticsearch is also d...

Introduction to reactive function toRef function ref function in Vue3

Table of contents Reactive Function usage: toRef ...

The latest mysql-5.7.21 installation and configuration method

1. Unzip the downloaded MySQL compressed package ...

Simple example of using Docker container

Table of contents 1. Pull the image 2. Run the im...

SQL implementation of LeetCode (175. Joining two tables)

[LeetCode] 175.Combine Two Tables Table: Person +...

JavaScript to achieve calendar effect

This article shares the specific code for JavaScr...

MySQL master-slave synchronization principle and application

Table of contents 1. Master-slave synchronization...

Make a nice flip login and registration interface based on html+css

Make a nice flip login and registration interface...

Inspiring Design Examples of Glossy and Shiny Website Design

This collection showcases a number of outstanding ...

Solution to the problem that Navicat cannot remotely connect to MySql server

The solution to the problem that Navicat cannot r...

MySQL stored procedure in, out and inout parameter examples and summary

Stored Procedures 1. Create a stored procedure an...

What are the new CSS :where and :is pseudo-class functions?

What are :is and :where? :is() and :where() are p...

How to limit the value range of object keys in TypeScript

When we use TypeScript, we want to use the type s...

Detailed explanation of small state management based on React Hooks

Table of contents Implementing state sharing base...