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 OverflowJavaScript.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
Videos
16:52
How To Make A Popup | HTML, CSS & JavaScript - YouTube
01:08
Build a Popup with JavaScript | 1-Minute Tutorial - YouTube
How To Make A Popup Using HTML, CSS And JavaScript ...
07:06
JavaScript Basics - how to make popup window with onclick method ...
16:55
Build a Popup With JavaScript - YouTube
11:54
JavaScript popup window - YouTube
Top answer 1 of 4
3
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');"
2 of 4
1
Try this simple piece of code:
<script>
function fullwindowpopup(){
window.open("newpopup.html","bfs","fullscreen,scrollbars")
}
</script>
<center>
<form>
<input type="button" onClick="fullwindowpopup()" value="CLICK HERE">
</form>
</center>
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 ...
Top answer 1 of 4
2
Just use window.open:
var referenceToNewWindow = window.open(url, name, features);
2 of 4
0
function popup(mylink, windowname, w, h){
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
href=mylink;
else
href=mylink.href;
window.open(href, windowname, "width="+w+",height="+h+",scrollbars=yes,toolbar=no" );
return false;
}
<a href="http://www.example.com" onClick="return popup(this, 'Title', '400', '500')">Link</a>
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.
Quackit
quackit.com โบ html โบ html_editors โบ scratchpad
Javascript Popup Window Onclick
Preview HTML code with this online HTML viewer. javascript popup window onclick.
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
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.