Click button to popup new window javascript

A classic!

To open a new window using JavaScript when a button is clicked, you can use the window.open() method. Here's an example:

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

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

In this example:

When the button is clicked, the openNewWindow() function is called, which opens a new window with the specified URL and dimensions.

You can also add additional parameters to the window.open() method to customize the new window further. For example:

Here's an updated example:

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

<script>
  function openNewWindow() {
    window.open("https://www.example.com", "_blank", "width=400,height=300,toolbar=no,menubar=no,scrollbars=yes");
  }
</script>

In this example, the new window will have a width of 400 pixels, a height of 300 pixels, no toolbar or menubar, and scrollbars enabled.