how to open new html page on button click in javascript code example

Example 1: js onclick redirect

<button onclick="location.href='www.yoursite.com'">Click Me</button>

Example 2: how to open new html page on button click

<!DOCTYPE html>
<html>
<head>
<script>
function openLink() {
  window.open("https://www.w3schools.com");
}
</script>
</head>
<body>

<form>
  <input type="button" value="Open Window" onclick="openWin()">
</form>

</body>
</html>

Example 3: how to open a new html page on button click in javascript

<button id="myButton" class="float-left submit-button" >Home</button>

<script type="text/javascript">
    document.getElementById("myButton").onclick = function () {
        location.href = "www.yoursite.com";
    };
</script>