mylink (the button's this) isn't a string, so you try to open mylink.href:

if (typeof(mylink) == 'string')
  href = mylink;
else 
  href = mylink.href;

But buttons don't have href properties, so it's as if you wrote:

window.open(undefined, 'about', 'width=400,height=200,scrollbars=yes');

which opens a blank page, as expected. If you want to open the same page as the link, use:

onclick="popup('newpopup.html', 'about');"
Answer from Paul Roub on Stack Overflow
🌐
Supsystic
supsystic.com › home › documentation › opening popup with link
How to open popup on click? Popup with HTML link
September 3, 2018 - Link with popup code will look like this – · <a href="<php echo do_shortcode('#ppsShowPopUp_100')?>">Subscribe To Our Newsletter</a> Or, if you know HTML basics, – you can insert “onclick” attribute of popup to any of element of your site.
🌐
W3Schools
w3schools.com › howto › howto_js_popup.asp
How To Create Popups
Fullscreen Video Modal Boxes Delete Modal Timeline Scroll Indicator Progress Bars Skill Bar Range Sliders Color Picker Email Field Tooltips Display Element Hover Popups Collapsible Calendar HTML Includes To Do List Loaders Badges Star Rating User Rating Overlay Effect Contact Chips Cards Flip Card Profile Card Product Card Alerts Callout Notes Labels Ribbon Tag Cloud Circles Style HR Coupon List Group List Group with Badges List Without Bullets Responsive Text Cutout Text Glowing Text Fixed Footer Sticky Element Equal Height Clearfix Responsive Floats Snackbar Fullscreen Window Scroll Drawing
Discussions

pop-up a window when the user clicks a button
I want my button to work just like above URL link 'my popup'. So I want to open the contents of newpopup.html in my pop-up window on a button click. My URL link for pop-up is working fine, I want the button to work thesame. ... Sign up to request clarification or add additional context in comments. ... More on stackoverflow.com
🌐 stackoverflow.com
How to do simple Popouts in Html
Please clarify. Are you having trouble creating the pop-up window? You can use a simple: Open to open a new window. Check the pop-up player at https://sensimedia.net and let me know if that's what you're trying to do. More on reddit.com
🌐 r/HTML
5
1
October 24, 2023
Pop up window with HTML CSS JS
Hi guys, can you help me out, please, on how to create a pop up window like the one that welcomes you at t the following site: https://coolors.co/ . The idea will be displaying a pic when you arrive on the site (i was thinking about using js or jquery, maybe the: .onload or maybe $( document ... More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
0
0
April 19, 2021
How to make a popup in HTML? Different methods - Installation & Integration - Popupsmart Community
Hey everyone! I’m trying to add a popup to my website to capture emails and promote discounts. I’d prefer a straightforward way to do it with HTML. So, how to make a popup in html? Can anyone share some methods? More on community.popupsmart.com
🌐 community.popupsmart.com
0
November 1, 2024
People also ask

How to create a popup in HTML with CSS?
To create a popup in HTML with CSS, use a hidden element that contains the popup content and apply styles for the popup's appearance, such as background color, borders, padding, and position (usually fixed or absolute). CSS animations can be used to add effects like fading or sliding. JavaScript is used to display the popup by changing the visibility or display property of the when triggered.
🌐
elfsight.com
elfsight.com › blog › how-to-make-a-popup-in-html
How to Make a Popup in HTML: Two Simple Solutions
What is the HTML tag for popups?
HTML does not have a specific tag for popups. Instead, popups are typically created using a combination of elements, which are styled and manipulated with CSS and JavaScript. The popup content is hidden initially and displayed when triggered by an event, such as clicking a button.
🌐
elfsight.com
elfsight.com › blog › how-to-make-a-popup-in-html
How to Make a Popup in HTML: Two Simple Solutions
How to make a popup card in HTML?
A popup card can be made using a element styled with CSS to appear like a card. You can create the popup card with a specific width, height, and padding to look like a modal or a dialog box. To show the popup card, you'll need to use JavaScript to toggle its visibility when a trigger, like a button click, occurs.
🌐
elfsight.com
elfsight.com › blog › how-to-make-a-popup-in-html
How to Make a Popup in HTML: Two Simple Solutions
🌐
SitePoint
sitepoint.com › javascript
How To Insert Text From Popup OnClick()
August 9, 2007 - Hey, I’m new to javascript, and I need some quick help on how to do something. I have a form, and one of the text boxes should be a URL to an image. I have a link to popup an image-upload script. On that popup, after th…
🌐
Asciidoctor
discuss.asciidoctor.org › Using-onclick-link-attribute-to-get-popup-window-td2964.html
Asciidoctor :: Discussion - Using onclick link attribute to get popup window
Asciidoctor :: Discussion · Using onclick link attribute to get popup window · ‹ Previous Topic Next Topic › · Locked 3 messages · wimalopaan · Reply | Threaded · Open this post in threaded view
Find elsewhere
🌐
Elfsight
elfsight.com › blog › how-to-make-a-popup-in-html
How to Make a Popup in HTML: Two Simple Solutions
December 3, 2025 - Trigger behavior. To create an HTML popup window onclick, modify the corresponding function in the <div> to trigger a different behavior, such as toggling a different popup or redirecting to another page.
🌐
HTML.com
html.com › javascript › popup-windows
Popup Windows Made Easy: Here's The JavaScript Code To Copy And Paste »
March 19, 2020 - Note that the name should be in single quotes (”). Let’s walk through the events that go into opening a popup. When the user clicks on a link, the browser triggers the onClick event, running the code in the onClick attribute.
🌐
Mobiscroll
demo.mobiscroll.com › javascript › popup
Javascript Popup Examples | Mobiscroll
3 weeks ago - Pop-over examples with customizable content, button configuration and behavior. For vanilla JS to use everywhere. Last update: Feb 24, 2026
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › Window › open
Window: open() method - Web APIs | MDN
By default, window.open opens the page in a new tab. If popup is set to true, it requests that a minimal popup window be used. The UI features included in the popup window will be automatically decided by the browser, generally including an address bar only.
🌐
W3Schools
w3schools.com › howto › howto_css_modals.asp
W3Schools.com
A modal is a dialog box/popup window that is displayed on top of the current page: Open Modal
🌐
GeeksforGeeks
geeksforgeeks.org › html › how-to-create-popup-box-using-html-and-css
How to Create Popup Box using HTML and CSS? - GeeksforGeeks
SweetAlert provides a simple way to create beautiful popup boxes with minimal code. ... <html> <head> <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script> <style> body { display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-color: #f0f0f0; } button { padding: 10px 20px; background-color: #17a2b8; color: #fff; border: none; border-radius: 5px; cursor: pointer; } </style> </head> <body> <button onclick="showPopup()">Show Popup</button> <script> function showPopup() { Swal.fire({ title: 'Welcome!', text: 'This is a SweetAlert popup.', icon: 'info', confirmButtonText: 'Cool' }); } </script> </body> </html>
Published   July 23, 2025
🌐
CodePen
codepen.io › imprakash › pen › GgNMXO
Pure css popup box
Minimize HTML Editor · Fold All · Unfold All · <h1>Popup/Modal Windows without JavaScript</h1> <div class="box"> <a class="button" href="#popup1">Let me Pop up</a> </div> <div id="popup1" class="overlay"> <div class="popup"> <h2>Here i am</h2> <a class="close" href="#">&times;</a> <div class="content"> Thank to pop me out of that button, but now i'm done so you can close this window.
🌐
Quackit
quackit.com › html › html_editors › scratchpad
Javascript Popup Window Onclick
Preview HTML code with this online HTML viewer. javascript popup window onclick.
🌐
PureBasic
purebasic.fr › home › board index › miscellaneous › off topic
Help with Javascript / html popup window - PureBasic Forums - English
September 23, 2022 - --> <html> <head> <title>Popup</title> <style type=text/css> .a11 {font-family:arial;font-size:11pt;font-weight:normal;color:#000000;} .button {width:75px;height:23px;} </style> </head> <body> <script language='javascript' type='text/javascript'> function doSubmit() { var doc = window.opener.document, theForm = doc.getElementById("theForm"), theForm.submit(); window.close(); } </script> <form id='theForm' action='popuptest.exe' method='get'> <p class='a11'>Choose:</p> <Select name='List' id='List' size='10' style='width:180;' class='a11' ondblclick='doSubmit()'> <option>1</option> <option>2</o
🌐
DevGenius
blog.devgenius.io › creating-a-pop-up-window-in-html-with-custom-html-content-using-javascript-7a7bdf1a0394
Creating a Pop-up Window in HTML with Custom HTML Content using JavaScript | by Popa Vlad | Dev Genius
March 6, 2025 - <a href="#" target="_blank" onclick="event.preventDefault(); window.open('about:blank').document.write('This is the content of the link.');">Click me</a>
🌐
Reddit
reddit.com › r/html › how to do simple popouts in html
r/HTML on Reddit: How to do simple Popouts in Html
October 24, 2023 -

Dear community I am desperately searching how to stile these simple popout windows that most radio stations use when you want a simple webplayer outsite of the regular website. I am interested on that topic because I want to build a simple web app to run in such a window. Looking forward to your suggestions!

Reference: Go to www.npo3fm.nl and click on the button „Open in venster in the lower right corner of the desktop version of the website.

🌐
SweetAlert2
sweetalert2.github.io
SweetAlert2
SweetAlert2 - a beautiful, responsive, customizable and accessible (WAI-ARIA) replacement for JavaScript's popup boxes
🌐
freeCodeCamp
forum.freecodecamp.org › html-css
Pop up window with HTML CSS JS - HTML-CSS - The freeCodeCamp Forum
April 19, 2021 - Hi guys, can you help me out, please, on how to create a pop up window like the one that welcomes you at t the following site: https://coolors.co/ . The idea will be displaying a pic when you arrive on the site (i was thinking about using js or jquery, maybe the: .onload or maybe $( document ).ready()) with black fading background and when you click on an “X” top right of the pic or anywhere else but on the image, the div disappear and you’ll see the body content.
🌐
Popupsmart Community
community.popupsmart.com › installation & integration
How to make a popup in HTML? Different methods - Installation & Integration - Popupsmart Community
November 1, 2024 - Hey everyone! I’m trying to add a popup to my website to capture emails and promote discounts. I’d prefer a straightforward way to do it with HTML. So, how to make a popup in html? Can anyone share some methods?
🌐
C# Corner
c-sharpcorner.com › blogs › javascriptopen-new-popup-window-on-button-click-event1
Javascript-Open new Popup Window on button click event
April 29, 2020 - Enter Path Of File Or Window Which You Want To Open : <input type="text" name="txtpath"/> <input type="button" value="Open" name="btnOpenPopup" onClick="OpenNewWindow(txtpath.value)" /> </FORM> </body> </html> People also reading · Membership not found · Ebook download View all ·