How to Redirect to Another Page in JavaScript on button click

Last Updated On Tuesday 24th May 2022

On Button Click ReDirect to Another Page

Sometimes You may want to use a button to link to another page or website.

Add an onclick event to the button.

	<button onclick="location.href = '';" id="myButton">
	<button id="myButton">Home</button>
	document.getElementById("myButton").onclick = function () {
     location.href = "";

Name A function to HTML Element

HTML Button onClick Redirect

	<button name="redirect" onClick="redirect()">
	function redirect() {
   let url = "";

You could change the action attribute of the form on Click the button

   $('form').attr('action','new path');

How to redirect to another page using JavaScript?


onclick redirect to another page
redirect on button click
button to redirect to another page html
button onclick to another page
how to redirect to another page in html
html button redirect to another page
javascript onclick redirect
javascript redirect to another page