return popup;
// Use it const win = window.open('/help', 'HelpWindow', getCenteredFeatures(900, 650)); window.open features
// Optional: Auto-clean reference when closed const checkClosed = setInterval(() => if (popup.closed) clearInterval(checkClosed); if (window.popupRef === popup) window.popupRef = null; return popup; // Use it const win = window
if (!popup) // Popup blocked alert('Popup was blocked. Please allow popups for this site or click the link manually.'); return null; if (popup.closed) clearInterval(checkClosed)
, 500);
This approach makes window.open() actually rather than annoying — respectful of user expectations, robust against blockers, and easy to reuse.