JavaScript Popup Generator
Generate javascript popup using the options shown.
About JavaScript Popup Generator
Help pages, size charts, terms of service and booking widgets are sometimes opened in a small separate window so visitors keep their place on the main page. Writing the window.open call with the right size parameters is fiddly if you do not code often. This tool produces a button snippet that opens a page you specify in a sized popup window.
How it works
You enter an http or https page URL, a width from 200 to 1600 pixels and a height from 200 to 1200 pixels; values outside those ranges are clamped and other URL schemes are rejected. The output is a <button> whose onclick calls window.open with the URL, a window name of 'popup', and the width and height. The URL is placed in single quotes and the whole onclick value is HTML-escaped, so URLs containing quotes or ampersands do not break the attribute. The snippet works as pasted and can be saved as popup.html.
How to use JavaScript Popup Generator
- Complete the available fields: Page URL, Width (px), Height (px). Use the field labels and examples shown in the workspace.
- Select “Create popup snippet” and check the result before copying or downloading it.
Worked example
Enter https://example.com/help, width 600 and height 500. The output is a button labeled 'Open page' whose onclick runs window.open('https://example.com/help', 'popup', 'width=600,height=500'). In the raw snippet the single quotes appear as ', which browsers decode before running the code.
Tips for a better result
- Paste the snippet as is; the ' and & entities in the onclick attribute are correct HTML and are decoded by the browser.
- Because the window name is always 'popup', several buttons on the same page reuse one window; rename it per button if you want separate windows.
- Popups opened from a direct button click are usually allowed, but test in your target browsers and on mobile, where popups often open as a new tab.
Frequently asked questions
Will popup blockers stop it?
Browsers generally allow windows opened directly by a user's click, which is how this button works. Blockers and mobile browsers may still open it as a tab or block it, so test on real devices.
Can I open a page on another website?
Yes. Any http or https URL is accepted. Some sites forbid being framed but still open fine in a popup window.
Can I change the button text?
The snippet always uses 'Open page'. Edit the text between the button tags after copying, and add a class if you want it styled like your other buttons.
What to check
Test generated markup in your own page. Sanitize untrusted content before inserting it into a live website.
Read the Privacy Policy for information about local processing, connected services and advertising.