How to create JavaScript Popup Window (open new window javascript)

Creating popup using JavaScript is not so tough, Here is the code that will do the magic. Just copy and paste and start using it!

There are a number of ways to create Javascript Popup

Method 1:

<html>
<head>

<script language="javascript" type="text/javascript">

function popup() {
window.open('https://theonlytutorials.com','name','height=500,width=600');
}
</script>

</head>
<body>
<a href="#" onclick="popup()">Open Popup</a>
</body>
</html>

See the line no. 7: Here I have given my site name instead you can give any page ‘popup.html’  or ‘subfolder/test.html’

window.open('https://theonlytutorials.com','name','height=500,width=600');

Method 2:

In the previous method, we call a function outside of the ‘<body>’ Tag. Instead, you can call in the ‘<a>’ tag itself, so no need to write the JavaScript Function inside the  ‘<script>’ Tag!

See the Code Below:

<a onclick="javascript:window.open('https://www.playvideos.in','PingStatistics','status=0,toolbar=0,menubar=0,scrollbars=1,location=0,resizable=0,width=500,height=800');" href="javascript:void(0);">
Click to Open Popup
</a>

That’s it

Leave a Reply

Theme: Overlay by Kaira
Agurchand