JS DOM: Pop-up New Window

By Xah Lee. Date: . Last updated: .

This page shows a JavaScript example of popping up a window.

to popup a window.

Code

<p>
<button id="button_jcW9N" type="button">Click Me</button>
to popup a window.
</p>
const button_jcW9N = document.getElementById("button_jcW9N");

const f_popup = () => {
 // window.open(URL, name, spec)

 const myWin = window.open("ex/pop_me.html", "Alice", "width=400, height=300, left=100");
 myWin.focus();
};

button_jcW9N.addEventListener("click", f_popup);