Referencing Windows

By: aathishankaran Emailed: 1728 times Printed: 2331 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

When working with single and multiple frames in your JavaScript application, you probably need to use additional ways to reference windows. JavaScript provides four references to windows. Each of the references are implemented as properties of the window object. 

Window and self 

User can refer to the current window as window or self. For example, the following two code lines are functionally the same: 

window.defaultStatus = "Welcome to the Goat Farm Home Page"

self.defaultStatus = "Welcome to the Goat Farm Home Page" 

Because both window and self are synonyms to the current window, you might find it curious that both are included in the JavaScript language. As shown in the previous example, the rationale is simply flexibility; you can use window or self as you want. 

However, as useful as window and self can be, it can easily become confusing to think about the logic behind it all. After all, an object's property that is used as an equivalent term for the object itself is rather unusual. Consequently, you might find it helpful to think of window or self as "reserved words" for the window object rather than its properties. 

Because window and self are properties of the window object, you cannot use both window and self in the same context. For example, the following code does not work as desired: 

window.self.document.write("< hl >Test. </hl >") 

Finally, in multiframe environments, window and self always refer to the window in which the JavaScript code is executed. 


            Frames are the same as window objects within a frameset. Within this multi-frame setting, you need to distinguish between the various frames displayed in the browser. The parent property of a window object helps you do that by referencing it’s parent-the window containing the <FRAMESET> definition. For example, if you want to retrieve some information about the current window's parent, you use the following example in Listing. 



<title>Child Window</title>

</head> <SCRIPT LANGUAGE=”JavaScript”>

<!- function getParentInfo()


myParentTitle = parent.document.title

alert(“My daddy's name is “ + myParentTitle)





<input type=”button” value=”Get Info” onClick=”getParentInfo () “>




JSP Home | All JSP Tutorials | Latest JSP 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


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 JSP
LifecycleException: service.getName(): "Catalina"; Protocol handler start failed: ` Permission denied <null>:80
JSP Alert Example
JSP CheckBox Example
Uploading an Image to a Database using JSP
Uploading a file to a server using JSP
A JSP page that gets properties from a bean
The page Directive in JSP
The taglib, tag, include, attribute and the variable Directive in JSP
Declarations in JSP
Scriptlets and Expressions in JSP
Tag Libraries in JSP
The Request Object in JSP
The Response Object in JSP
The Out Object in JSP
The Session Object in JSP

More Latest News
Most Viewed Articles (in JSP )
JSP Example to connect to MS SQL database and retrieve records
LifecycleException: service.getName(): "Catalina"; Protocol handler start failed: ` Permission denied <null>:80
Automatically Refreshing a JSP
JSP CheckBox Example
JSP Alert Example
JSP Program for display Date
What are the different scopes in JSP? Connection refused: connect
Comparison operators in JSP
Sending Email using JSP
The Response Object in JSP
Embedding java codes in jsp sciptlets
JSP pages in servlet
Example Using Initialization Parameters
Simple HTML-Building Utilities
Most Emailed Articles (in JSP)
Combining Scriptlets with HTML
Form processing in JSP
Protecting your website with a login page
The Servlet Life Cycle
Closing Windows
WebClient: Talking to Web Servers Interactively
Drawbacks of the JSP Model 1 Architecture
Select Object
Working with Status Bar Messages Connection refused: connect
What are the different scopes in JSP?
Calling JSP from a batch file
Embedding a QuickTime movie in a JSP