method - a step ahead series

The syntax of the method is given below:

open (URL, windowName[, windowFeatures])


This is the URL of the page which open in the new window.
It could be blank.


A name to be given to the new window.
The name can be used to refer this window again.


It contains the various window
features for the popup window i.e. status bar, address bar etc

The following lines of code, open a new browser window with standard features : ("","MsDn Interview Questions");

Changing the features of the Popup

By using some stuff we can control the features of the popup.

The following code opens a window with a status bar
and no extra features: ("","MsDn Interview Questions","status=1");

The code below opens a window with toolbar and status bar : ("","MsDn Interview Questions","status=1,toolbar=1");

The following is the table tells the features :

status The status bar.
toolbar The standard browser toolbar.
location The URL Location entry field.
menubar The menu bar of the window
directories The standard browser directory buttons.
resizableAllow/Disallow the user to resize the window.
scrollbars Enable the scrollbars if the document is bigger than the window
heightSpecifies the height of the window in pixels.
width Specifies the width of the window in pixels.

Example :

The Code below opens a popup window when you enter the page:


<title>Open Blank Popup WIndow </title>



function openBlank()

testwindow= ("", "mywindow",




onload="javascript: openBlank()">

<H1>Open Blank Popup WIndow</H1>

Here, URL is blank. This will open a blank window.

Test code here:

Open Blank Window

Popup On Exit

The following code pops up a window when the user exits a page.


<title>Window Exit Alert </title>



function exitAlert()
my_window= ("",


my_window.document.write('<H1>Exiting Window... </H1>');

onunload="javascript: exitAlert()"

<H1>Window Exit Alert</H1>

Test code here: Exit Alert

Opening same url in New window:



<title>Open Same window </title>


<SCRIPT language="JavaScript">

function OpenMe()


var url = self.location;,"MySelf","left=20,top=20,width=500,height=500,toolbar=1,resizable=0");



<body >

<H1>Open Same window</H1>

Test code here: <a href="javascript:OpenMe();">Open Me</a>



We can also open the current page in new window,

Test code here: Open Me


  • Windows.Open method (34273-21735-226938-18746-windowOpenExample1.html)
  • Article by Gaurav Aroraa
    Gaurav is a Microsoft Technology Specialist professional. He has awarded lifetime membership from Computer Society of India (CSI). He has more than 13yrs of experience in the industry. Currently, he is working in the capacity of Solution Architect with an MNC. He is serving to the various communities since 1999.

    Follow Gaurav Aroraa or read 149 articles authored by Gaurav Aroraa


    No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: