How to open popup window in javascript

Sometimes we need to open new popup window (browser) through javascript without disturbing main window. Popup windows are different to simply opening a new browser window. Here I am sharing different types of popup windows with different properties.

Popup window javascript syntax“url”, “window-Name”, “window-Features”);

url: Page url to open new windows,

window-Name : name of the window

window-Features: properties of the new popup window like width, height

Standard Popup Window (““,”mywindowName“);

Popup Window with toolbar (““,”mywindowName“, “toolbar=1“);

OR (““,”mywindowName“, “toolbar=yes“);

Popup Window with status (““,”mywindowName“, “status=1“);

OR (““,”mywindowName“, “status=yes“);

Popup Window with menubar (““,”mywindowName“, “menubar=1“);

Popup Window with width (““,”mywindowName“, “width=350“);

Popup Window with height (““,”mywindowName“, “height=350“);

Popup Window with resizable (““,”mywindowName“, “resizable=1“);

OR (““,”mywindowName“, “resizable=yes“);

Popup Window with scrollbars (““,”mywindowName“, “scrollbars=1“);

OR (““,”mywindowName“, “scrollbars=yes“);

Popup Window move to desired location

var (““,”mywindowName“);


Popup Window with all windows features

var my_new_window=““, “mywindowName“, “status=1,scrollbars=1,location=1,width=350,height=350“);
my_new_window.moveTo(0, 0);

Popup Window with all windows features parameterize

function popup(url)
                var width=800;
                var height=600;
                var left   = (screen.width  - width)/2;
                var top    = (screen.height - height)/2;

                var params = 'width='+width+', height='+height;
                params += ', top='+top+', left='+left;
                params += ', directories=no';
                params += ', location=no';
                params += ', menubar=no';
                params += ', resizable=yes';
                params += ', scrollbars=yes';
                params += ', status=no';
                params += ', toolbar=no';
      ,'windowname5', params);
                return false;

Above javascript function you can call from your html code as follows.

 <title>JavaScript Popup Example 3</title>
<body onload="javascript: popup('')">
<h1>JavaScript Popup Example 3</h1>

The Author


Hello! I am Narayanaswamy founder and admin of I have been working in IT industry more than 7 years. NarayanaTutorial is my web technologies blog. My specialties are Java / J2EE, Spring, Hibernate, Struts, Webservices, PHP, Oracle, MySQL, SQLServer, Web Hosting and Website Development. I am a self learner and passionate about training and writing. I am always trying my best to share my knowledge through my blog.

Leave a Reply