Window Object

By: aathishankaran Viewed: 1388 times  Printer Friendly Format    

Creating, a window 

To create a window use the following syntax: 

            Window_object_name=]open(“url","Window name"[,"attribute"]) 

The URL parameter specifies what content appears in the new window. If you specify a value, the browser attempts to locate and display the specified document: 

        newWindow=“", "Home Page","") 

Alternatively, you can display a blank page by specifying an empty string ("") as the URL parameter. Use this technique if you want to create an HTML page dynamically using JavaScript: 

newWindow =“", “DynamicPage", “")

newWindow.document.write(“<Hl>Document created using JavaScript.</Hl>") newWindow.document.close () 

Specifying Window Attributes 

The windowAttributes parameter is important as you display windows because it

Lets you customize the look of the window you are opening. The window Attributes parameter is optional; not including it gives you a window identical to the current one with respect to attributes. 




Width of window in pixels


Height of window in pixels


Show/hide browser toolbar


Show/hide browser menu bar


Show/hide browser horizontal and vertical scrollbars


Allow/disallow resizing of browser window


Show/hide browser status bar


Show/hide URL location box


Show/hide secondary toolbar (Netscape)


Copy current window's Go history for new window

             The width and height attributes specify the dimensions of the window in pixels.

The remaining attributes are set by using Boolean values: True values are either 1, yes, or the attribute alone; false values are either 0, no, or more simply, leaving it out altogether. For example, if you want to display the new window with only a toolbar and menu bar, you use the following line: 

newWindow ="”,"my Window”, "toolbar=l,   menubar=l”) 

The following syntaxes are also valid: 

newWindow = window. open ("", "myWindow” , "toolbar=yes , menubar=yes”)

newWindow = window. open (" “, "myWindow “ , "toolbar, menubar”) 

As you can see, you can simply leave out those attributes that are not specified. They are assumed to have false values. 





Example For Window Object



<Hl>Example for Window Object</Hl>



<Form Name=form1>


<Input Type=Button


Value=”Open java”



<Input Type=Button



onClick=”‘’,’’,'toolbar=0, menubar=0, status=0')

win.document.write ('<H1>Help For The page</H1>' );

win.document.write('<ol>') ;

win.document.write ('<li>Click on the Open Hotmail' );

win. doo.nnent. write ( '<li>The Hotmail web page is loaded') ;

win.document.write('<li>If Hotmail is not loaded then, You may not have connected to Internet');








Most Viewed Articles (in Java )

Latest Articles (in Java)

Comment on this tutorial