Window.open Features -
// Usage openSmartPopup('https://example.com', 'HelpfulWindow', 900, 700); | Feature | Benefit | |---------|---------| | Centered positioning | User-friendly, doesn't open off-screen | | Ref tracking | Reuses existing window instead of duplicate popups | | Focus handling | Brings existing popup to front if already open | | Fallback alert | Informs user if popup blocker interferes | | Sensible defaults | Includes toolbars, scrollbars, location bar for usability | | Auto cleanup | Removes reference when popup closes | Minimal version (if you just need the feature string): function getCenteredFeatures(w = 800, h = 600) const left = (screen.width - w) / 2; const top = (screen.height - h) / 2; return `width=$w,height=$h,left=$left,top=$top,resizable=yes,scrollbars=yes,toolbar=yes,location=yes`;
, 500);
// Store reference window.popupRef = popup; window.open features
// Focus the new window popup.focus();
return popup;