Window Object

By: aathishankaran Emailed: 1729 times Printed: 2338 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

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>


Java Home | All Java Tutorials | Latest Java Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.



Bookmark and Share

Comments(0)


Be the first one to add a comment

Your name (required):


Your email(required, will not be shown to the public):


Your sites URL (optional):


Your comments:



More Tutorials by aathishankaran
Web Security Issues
The Web User's Perspective
Server-side plug-Ins
The best way to avoid security vulnerabilities with new server
JavaScript Security
Window Object
Working with Status Bar Messages
Retrieving a Portion of a String
Referencing Windows
Math Object
Frame Object
Document Object
Closing Windows
Built-in Object in Javascript
Textarea Object

More Tutorials in Java
Update contents of a file within a jar file
Tomcat and httpd configured in port 8080 and 80
Java File
Java String
Count number of vowels, consonants and digits in a String in Java
Reverse a number in Java
Student marks calculation program in Java
Handling Fractions 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
Multiple Inheritance sample in Java
Java program using Method Overriding
Java program to check if user input is an even number

More Latest News
Most Viewed Articles (in Java )
How to Send SMS using Java Program (full code sample included)
Method Overriding in Java
wait(), notify() and notifyAll() in Java - A tutorial
XML and Java - Parsing XML using Java Tutorial
What is Java?
InetAddress Example program in Java
How to use ArrayList in Java
Vector example in Java
Student marks calculation program in Java
Method Overloading (function overloading) in Java
Execute system commands in a Java Program
The Basic Structure of a Simple Java program
Stack example in Java - push(), pop(), empty(), search()
Recursion in java
Read from a COM port using Java program
Most Emailed Articles (in Java)
Vector in Java - Sample Program
Use of return statement in Java
Taking the size of an Array at runtime & generate random numbers to populate the Array
instanceof operator example in Java
3-D Secure Payment or 3DS - (3-Domain Secure Payment)
What is a Java Package and how to use it?
How to use Iterator in Java
J2EE Components
The modulus Operators
The java Buzzwords
The Basic Structure of a Simple Java program
Java Chat Client Sample Applet
Reverse a number in Java
MultiLevel Inheritance sample in Java
Type Casting in Java