Home > Blockchain >  Redirecting with a button
Redirecting with a button

Time:09-16

How do I redirect a user to a page if they click a button? This is for a login page. I have tried href but it doesn't work. I don't know .php so I am using js.

CodePudding user response:

<!DOCTYPE html>
<html>
<body>


<button onclick="myFunction()">redirect</button>

<script>
function myFunction() {
  window.location.href = "http://stackoverflow.com";
}
</script>

</body>
</html>

CodePudding user response:

Create an HTML button that acts like a link
<a href='https://ide.geeksforgeeks.org/'>
    <button>
        Click Here
    </button>
</a>
  •  Tags:  
  • html
  • Related