Create a popup window in JavaScript

To create a simple popup window in JavaScript you need to use the window object of the JavaScript and supply some parameters as shown below.

(The code is simplified for easier understanding, use good standards for real development)

Main window:

<html>
<script language="javascript">
function popup()
{
window.open("popup.htm","_blank","height=200,width=400,status=yes,toolbar=no,menubar=no")
}
</script>
<body>
<input type=button value="Open Popup" onclick="javascript:popup()">
</body>
</html>

Popup window(popup.htm):

<html>
<body>
This is a popup...
</body>
</html>

You can change the "height=200,width=400,status=yes,toolbar=no,menubar=no" as you wish to customize. For more info on window.open() method see http://msdn.microsoft.com/en-us/library/ms536651%28VS.85%29.aspx.

For more advanced options related to popup windows using JavaScript check out this post.

Bookmark / Share

Write your comment..




biuquote
  • Comment
  • Preview
Loading