Javascript popup window code generator
Generate the HTML, CSS and JavaScript for a popup window opened by a button, a link, or automatically on page load/unload - the example button below updates live as you fill in the form.About JavaScript popup windows
A popup window (window.open()) opens a second browser window separate from the page that triggered it - once common for things like image galleries, chat widgets and secondary content. Modern browsers block popups by default unless they're opened as a direct result of a click or tap, which is why "button" and "link" triggers here work reliably while "when page loads" and "when page unloads" mostly don't - see the mistakes callout above.
Where a real popup still makes sense: print-friendly views, external auth flows some third-party services still rely on, or a small utility window (like a calculator or reference panel) meant to sit alongside the main page. For anything meant to grab attention automatically, an on-page modal or banner is the reliable modern substitute - it can't be blocked, and it works the same on mobile, where separate popup windows generally don't exist at all.
Frequently asked questions
Will "when page loads" or "when page unloads" actually work?
Rarely, in practice. Every major browser blocks popups that open without a direct click or tap from the visitor, and an automatic popup on page load or unload is exactly the pattern popup blockers were built to stop. Button and link triggers work reliably everywhere since they're tied to a real click - if you need something to appear automatically, an on-page banner or modal (not a separate window) is the reliable modern equivalent.
Which browser options (menu bar, toolbar, etc) actually do anything?
Realistically, very few of them. Current versions of Chrome, Firefox, Edge and Safari mostly ignore all of these settings now - resizable, scrollbars, menu bar, tool bar and status bar included - since browsers have moved toward giving popups the same minimal chrome regardless of what's requested, for consistency and security. They're still included in the generated code because it costs nothing to leave them in, and some older or embedded browsers do still respect them. There's no working "full screen" option any more in any current browser, which is why that choice was removed here entirely.
Does the hover effect work with the stylesheet or in-page CSS option too?
Yes, whichever style option you choose. Inline mode adds the hover color/background/text-decoration changes directly on the tag as onmouseover and onmouseout attributes; stylesheet and in-page mode instead generate a proper :hover CSS rule alongside the button or link's own styling.
What does "do not display another popup for X hours" actually do?
It sets a cookie in the visitor's browser the first time the popup shows, and checks for that cookie on later visits - if it's still there, the popup is skipped. It only applies to the "when page loads"/"when page unloads" methods (a button or link is a deliberate click each time, so there's nothing to suppress). Note it depends on the visitor allowing cookies and not clearing them, and only remembers per-browser, not per-person.
