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
๐ŸŒ
JavaScript.info
javascript.info โ€บ tutorial โ€บ frames and windows
Popups and window methods
The open call returns a reference to the new window. It can be used to manipulate its properties, change location and even more. In this example, we generate popup content from JavaScript:
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ how-to-open-a-popup-on-click-using-javascript
How to Open a Popup on Click using JavaScript ? - GeeksforGeeks
August 5, 2025 - <!DOCTYPE html> <html> <head> <title>Using display property</title> <style> #popupDialog { display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); padding: 20px; background-color: #fff; border: 1px solid #ccc; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); z-index: 1000; } #overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.5); z-index: 999; } h1 { color: green; } </style> </head> <body> <h1>GeeksforGeeks</h1> <h3>Using display property</h3> <button onclick="popupFn()"> Open Popup </button> <div id="overla
๐ŸŒ
Quackit
quackit.com โ€บ javascript โ€บ popup_windows.cfm
JavaScript Popup Windows
You can put the above code into ... a popup window. Doing this allows you to cut down on the amount of code you use when using popups. Here's a working example. ... The above script creates a function that accepts a parameter called "url". You can now call the function in your HTML as follows. ... Here, we create a normal HTML link, but we also add the onclick event handler to trigger our JavaScript ...
๐ŸŒ
HTML.com
html.com โ€บ javascript โ€บ popup-windows
Popup Windows Made Easy: Here's The JavaScript Code To Copy And Paste ยป
March 19, 2020 - The URL of the page being linked to is in the HREF attribute. Weโ€™ve added an additional attribute called onClick. Copy the code as it is into your link, with only a small modification. The second argument of the popup() โ€” โ€˜notesโ€™ โ€” indicates name of the popup window.
๐ŸŒ
W3Schools
w3schools.com โ€บ howto โ€บ howto_js_popup.asp
How To Create Popups
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
๐ŸŒ
W3docs
w3docs.com โ€บ javascript
How to Create a Popup Form Using JavaScript
function openForm() { ... of the modal, close it window.onclick = function (event) { let modal = document.getElementById('loginPopup'); if (event.target == modal) { closeForm(); } } It is not too difficult to have ...
Find elsewhere
๐ŸŒ
Quackit
quackit.com โ€บ html โ€บ html_editors โ€บ scratchpad
Javascript Popup Window Onclick
Preview HTML code with this online HTML viewer. javascript popup window onclick.
๐ŸŒ
Mobiscroll
demo.mobiscroll.com โ€บ javascript โ€บ popup
Javascript Popup Examples | Mobiscroll
Pop-over examples with customizable content, button configuration and behavior. For vanilla JS to use everywhere. Last update: Feb 24, 2026
๐ŸŒ
W3docs
w3docs.com โ€บ learn-javascript โ€บ popups-and-window-methods.html
Mastering JavaScript: Comprehensive Guide to Popups and Window Methods
When clicked, it opens a new popup window with dimensions 400x400 pixels and displays a welcoming message. Controlling the content and behavior of popups is crucial for ensuring they contribute positively to the user experience without being ...
๐ŸŒ
W3Schools
w3schools.com โ€บ howto โ€บ howto_css_modals.asp
How To Make a Modal Box With CSS and JavaScript
Learn how to create a Modal Box with CSS and JavaScript. A modal is a dialog box/popup window that is displayed on top of the current page: Open Modal
๐ŸŒ
QuirksMode
quirksmode.org โ€บ js โ€บ popup.html
JavaScript - Popups
First check if the browser supports ... the new window. ... Finally we return false. This is to prevent the browser from following the actual link. ... The normal link leads to the page you want to show, while the popup script is called in the onclick event handler. When the script is called, it returns false to prevent the browser from following the link. The trick is that when JavaScript is disabled ...
๐ŸŒ
Linux Hint
linuxhint.com โ€บ open-a-popup-window-in-javascript-using-onclick
How to Open a Popup Window in JavaScript Using Onclick?
Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use
๐ŸŒ
PopupSmart
popupsmart.com โ€บ popupsmart conversion rate optimization & digital marketing blog โ€บ how to build a popup that opens on a button click
How to Build a Popup That Opens on a Button Click
January 26, 2024 - // Get the modal var modal = ... document.getElementsByClassName("close")[0]; // When the user clicks the button, open the modal btn.onclick = function() { modal.style.display = "block"; } // When the user clicks on (x), close the ...
๐ŸŒ
Quora
quora.com โ€บ How-do-you-create-a-new-popup-window-in-JavaScript
How to create a new popup window in JavaScript - Quora
Answer (1 of 2): I would suggest you to use window.open() Here is the syntax and parmeter of window.open(): window.open(URL, windowName, [windowFeatures]) URL: The URL of the page to open.
๐ŸŒ
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 - <script type="text/javascript"> ... To Open : <input type="text" name="txtpath"/> <input type="button" value="Open" name="btnOpenPopup" onClick="OpenNewWindow(txtpath.value)" /> </FORM> </body> </html> People also reading ...
๐ŸŒ
Laurentian
web.cs.laurentian.ca โ€บ rsgrewal โ€บ c2206 โ€บ javascript โ€บ examples โ€บ windows โ€บ windows.html
Opening a pop up window
Close pop up window and click the following link to open it again. ... This method uses a special form of link which just executes a javascript function. ... Other useful features are menubar="yes", resizable="yes", scrollbars="yes", toolbar="yes", and status="yes". Note that the javascript designers cannot spell: use resizable not resizeable. The default values are "no". Click the following link to see a popup window with these values turned on.
๐ŸŒ
Javascript-array
javascript-array.com โ€บ scripts โ€บ window_open
Javascript window.open, also fullscreen and centered popup window ยซ JavaScript DHTML Tutorials
<script type="text/javascript"> ... {newwin.focus()} return false; } // --> </script> <a href="javascript: void(0)" onclick="popup('popup.html')">Fullscreen popup window</a>...