Window Object
By: aathishankaran 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=
window.open(“http://www.java-samples.com", "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 = window.open(“",
“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.
Attribute |
Description |
width |
Width of window in pixels |
height |
Height of window in pixels |
toolbar |
Show/hide browser toolbar |
Menubar |
Show/hide browser menu bar |
Scrollbars |
Show/hide browser horizontal and vertical scrollbars |
resizable |
Allow/disallow resizing of browser window |
Status |
Show/hide browser status bar |
Location |
Show/hide URL location box |
Directories |
Show/hide secondary toolbar (Netscape) |
Copyhistory |
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 = window.open("â€,"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
<Html>
<Head>
<Title>
Example For Window Object
</Title>
<Body>
<Hl>Example for Window Object</Hl>
<H2></H2>
<Hr>
<Form Name=form1>
<Center>
<Input Type=Button
Name=btn1
Value=â€Open javaâ€
onClick=†window.open(‘http://www.java-samples.com’,’’);
“>
<Input Type=Button
Name=btn2
Value=â€Helpâ€
onClick=â€
win=window.open(‘’,’’,'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');
win.document.write('</ol>');
“>
<Hr>
</Center>
</Form>
</Body>
</Html>
Comment on this tutorial
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Subscribe to Tutorials
Related Tutorials
Program using concept of byte long short and int in java
Update contents of a file within a jar file
Tomcat and httpd configured in port 8080 and 80
Count number of vowels, consonants and digits in a String in Java
Student marks calculation program in Java
Calculate gross salary in Java
Calculate average sale of the week in Java
Vector in Java - Sample Program
MultiLevel Inheritance sample in Java