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 number of ways to create Javascript Popup

Method 1:


<html>
<head>

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

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

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

See the ouput for the above code here:

Open Popup

When you click the above link my site will open in a new window!.

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('http://www.theonlytutorials.com','name','height=500,width=600');

[ad][ad]

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('http://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>


Click to Open Popup

Test the Above link by Clicking it!.

Leave a Reply