Button click js open a new page

You can use the window.open() method in JavaScript to open a new page when a button is clicked. Here is an example:

<button onclick="openNewPage()">Click me!</button>

<script>
  function openNewPage() {
    window.open("https://www.example.com", "_blank");
  }
</script>

In this example, when the button is clicked, the openNewPage() function is called, which opens a new page at the URL https://www.example.com in a new tab or window.

You can also specify additional options for the new page, such as:

For example:

<button onclick="openNewPage()">Click me!</button>

<script>
  function openNewPage() {
    window.open("https://www.example.com", "_blank", "width=800,height=600");
  }
</script>

This would open a new page at the URL https://www.example.com in a new tab or window with a width of 800 pixels and a height of 600 pixels.

You can also use the location.href property to set the URL of the new page:

<button onclick="openNewPage()">Click me!</button>

<script>
  function openNewPage() {
    window.location.href = "https://www.example.com";
  }
</script>

This would set the URL of the current page to https://www.example.com when the button is clicked.