Open Popup Window in JavaScript

- 1 minute read

This one-liner, which uses the default window.open method, is all you need to open a popup window in JavaScript:

window.open(`https://example.com`, `newWindow`);

When executed, the above line of code will open https://example.com in a new browser window.

Keep in mind that some browsers might try and block popup windows or warn the user before displaying them!

Link to this section Conclusion

Hopefully you found this useful!

Just remember to avoid spamming your users with annoying popup windows everywhere…