Logo

Navigation
  • Home
  • Services
    • ERP Solutions
    • Implementation Solutions
    • Support and Maintenance Solutions
    • Custom Solutions
    • Upgrade Solutions
    • Training and Mentoring
    • Web Solutions
    • Production Support
    • Architecture Designing
    • Independent Validation and Testing Services
    • Infrastructure Management
  • Expertise
    • Microsoft Development Expertise
    • Mobile Development
    • SQL Server Database and BI
    • SAP BI, SAP Hana, SAP BO
    • Oracle and BI
    • Oracle RAC
  • Technical Training
    • Learn Data Management
      • Business Intelligence
      • Data Mining
      • Data Modeling
      • Data Warehousing
      • Disaster Recovery
    • Learn Concepts
      • Application Development
      • Client Server
      • Cloud Computing Tutorials
      • Cluster Computing
      • CRM Tutorial
      • EDI Tutorials
      • ERP Tutorials
      • NLP
      • OOPS
      • Concepts
      • SOA Tutorial
      • Supply Chain
      • Technology Trends
      • UML
      • Virtualization
      • Web 2.0
    • Learn Java
      • JavaScript Tutorial
      • JSP Tutorials
      • J2EE
    • Learn Microsoft
      • MSAS
      • ASP.NET
      • ASP.NET 2.0
      • C Sharp
      • MS Project Training
      • Silverlight
      • SQL Server 2005
      • VB.NET 2005
    • Learn Networking
      • Networking
      • Wireless
    • Learn Oracle
      • Oracle 10g
      • PL/SQL
      • Oracle 11g Tutorials
      • Oracle 9i
      • Oracle Apps
    • Learn Programming
      • Ajax Tutorial
      • C Language
      • C++ Tutorials
      • CSS Tutorial
      • CSS3 Tutorial
      • JavaScript Tutorial
      • jQuery Tutorial
      • MainFrame
      • PHP Tutorial
      • VBScript Tutorial
      • XML Tutorial
    • Learn Software Testing
      • Software Testing Types
      • SQA
      • Testing
  • Career Training
    • Career Improvement
      • Career Articles
      • Certification Articles
      • Conflict Management
      • Core Skills
      • Decision Making
      • Entrepreneurship
      • Goal Setting
      • Life Skills
      • Performance Development
      • Personal Excellence
      • Personality Development
      • Problem Solving
      • Relationship Management
      • Self Confidence
      • Self Supervision
      • Social Networking
      • Strategic Planning
      • Time Management
    • Education Help
      • Career Tracks
      • Essay Writing
      • Internship Tips
      • Online Education
      • Scholarships
      • Student Loans
    • Managerial Skills
      • Business Communication
      • Business Networking
      • Facilitator Skills
      • Managing Change
      • Marketing Management
      • Meeting Management
      • Process Management
      • Project Management
      • Project Management Life Cycle
      • Project Management Process
      • Project Risk Management
      • Relationship Management
      • Task Management
      • Team Building
      • Virtual Team Management
    • Essential Life Skills
      • Anger Management
      • Anxiety Management
      • Attitude Development
      • Coaching and Mentoring
      • Emotional Intelligence
      • Stress Management
      • Positive Thinking
    • Communication Skills
      • Conversation Skills
      • Cross Culture Competence
      • English Vocabulary
      • Listening Skills
      • Public Speaking Skills
      • Questioning Skills
    • Soft Skills
      • Assertive Skills
      • Influence Skills
      • Leadership Skills
      • Memory Skills
      • People Skills
      • Presentation Skills
    • Finding a Job
      • Etiquette Tips
      • Group Discussions
      • HR Interviews
      • Interview Notes
      • Job Search Tips
      • Resume Tips
      • Sample Resumes
 

JavaScript DOM Window Object

By Exforsys | on June 21, 2007 |
JavaScript Tutorial

JavaScript DOM Window Object

In this JavaScript tutorial, you will learn about closed property and name property, defaultStatus, status, self property of JavaScript Window object

closed Property of Window Object:

The closed property of a Window object returns a Boolean variable denoting whether window has been closed or not. The closed property tells you whether or not a window opened using window.open(). Once a window is opened in JavaScript, its closed property is immediately initialized, with a value of false. When the newly opened window is closed, then the closed property of this window is set to a value of true. A programmer can study whether a window is closed or open using the closed property of a Window object.

General syntax of closed property of Window Object:


windowname.closed

For example:

<html>
<head>
<script type="text/javascript">
function callClosed()
{
document.write("’ExforsysWindow’ is closed!")
}
function callopen()
{
document.write("’ExforsysWindow’ is not closed and is Open!")
}
function funcheck()
{
if (ExforsysWindow.closed)
callClosed()
else
callopen()
}
</script>
</head>
<body>
<script type="text/javascript">
ExforsysWindow=window.open(”,”,’width=100,height=100′)
ExforsysWindow.document.write("The Window is ‘ExforsysWindow’")
</script>

<input type="button"
value="Is the Window ‘ExforsysWindow’ Closed?"
onclick="funcheck()" />
</body>
</html>

In the above example a new window object ExforsysWindow is opened using window.open statement. The opening of ExforsysWindow gives a window ExforsysWindow with message displayed as


The Window is ‘ExforsysWindow’

A button is created to check whether the window object ExforsysWindow is closed or open. This is done as follows:

On the clicking of this button, the function funcheck() is called. The statement ExforsysWindow. closed is used to check whether the current state of the window ExforsysWindow is open or closed. The value returned by this statement would be false if the window is open and if the window ExforsysWindow is closed, then the value returned by this statement would be true.

If the window ExforsysWindow is closed, the value returned is true. The function callClosed() in if block is called and the statement displayed would be:


‘ExforsysWindow’ is closed!

If the window ExforsysWindow is open, then the value returned is false. The function callopen() in else block is called and the statement displayed would be:


‘ExforsysWindow’ is not closed and is Open!

name Property of Window Object:

The name property of a Window object is used for setting or returning the name of the window. The name property is a string containing the window’s name.

NOTE: it is not possible to define them dynamically.

General syntax of name property of Window Object:


‘ExforsysWindow’ is closed!

for example

<html>
<head>
<script type="text/javascript">
function displayWindow()
{
document.write("The Name of window is: " + createdWindow.name)
}
</script>
</head>
<body>
<script type="text/javascript">
createdWindow=window.open(”,’Exforsys’,’width=100,height=100′)
</script>

<input type="button"
value="What’s the name of ‘createdWindow’?"
onclick="displayWindow()" />
</body>
</html>

In the above example, the program first creates a window createdWindow and then a button is displayed with text as:


What’s the name of ‘createdWindow’

When this button is clicked, the function displayWindow() is called. Then the message and the name of the window is displayed on the screen as:


The Name of window is: Exforsys

Using the function displayWindow() creates Window.name statement in document.write statement. This creates Window.name and has the name of window as Exforsys stored in it.

JavaScript Window Object defaultStatus Property: The defaultStatus property is a Read/Write property that can be set at any time and defines the default message displayed in a window’s status bar. It is possible to set or return the default text in the status bar of the window using this property. The text is displayed during the loading of the page.

General syntax of defaultStatus property of Window Object:


window.defaultStatus=textmessage

For example:


window.defaultStatus = "Exforsys -Example of Status bar message to show defaultStatus property"

A complete program as example to understand the usage of this property:


<html>
  <head>
    <script type="text/javascript">
      window.defaultStatus="Exforsys -Example of Status bar
      message to show defaultStatus property
"
   </
script>
  </head>
 </html>

The output of the above script is


Exforsys -Example of Status bar message to show defaultStatus property

The above message appears in the Status bar of the window as default text.

status property of Window Object:

The status property is used to set or return the text in the status bar of a window. For a window, the defaultStatus property reflects the default message displayed in the status bar at the bottom of the window. This defaultStatus property is different from status property. The status property reflects a priority or transient message in the status bar, such as the message that appears when a mouseOver event occurs over an anchor. The defaultStatus property differs to the status property.

In defaultStatus property, the text is always shown in the status bar. The status property can be used to temporarily alter the status bar text. The status property can be used to temporarily change the text displayed in the status bar of a browser window. It is commonly used to set the status bar text when the mouse is moved over links in a document, so that more explanatory text, instead of a URL is displayed.

General syntax of status property of Window Object:


window.status=textmessage

For example:


window.status = "Exforsys -Example of Status bar message to show status property"

The usage looks similar to that of defaultStatus property however, the status property can be set at any time. For example, the programmer can place set the status bar message on the onMouseOver event as follows:


 <html>
  <head>
    <script type="text/javascript">
    
<A HREF="http://www.exforsys.com"
    
onMouseOver="window.status=’Exforsys -Example of
     Status bar message to show status property’;
     return true
">Place Mouse and See Status Bar</A>
   </
script>
  </head>
 </html>

The output of the above script is


Exforsys -Example of Status bar message to show status property

The above message appears in the Status bar of the window only when the user places the mouse over the link displayed as Place Mouse and See Status Bar.

{mospagebreak title=JavaScript Window Object Self Property}

JavaScript Window Object defaultStatus Property: The defaultStatus property is a Read/Write property that can be set at any time and defines the default message displayed in a window’s status bar. It is possible to set or return the default text in the status bar of the window using this property. The text is displayed during the loading of the page.


window.self

An example to understand this concept:


 <html>
  <head>
    <script type="text/javascript">
     function checkwindow()
   
 {
      if (
window.top!=window.self)
     
{
       
 document.write("The window is not current
         window!!!!!
")
     
}
     else
    
{
       
document.write("The window is current window!!!!!")
    
}
    }

  
</script>
 </head>
 <
body>
    <input
type="button" onclick="checkwindow()"
   
value="Check the Window by clicking Here">
 </body>
</html>

In the above example a button is displayed with message


Check the Window by clicking Here

When this button is clicked, the function checkwindow() is called and the Current Window status is checked. If the Window top is equal to window.self (which has the reference to the current window) then else statement gets fired and the message:


The window is current window!!!!!

is displayed.

If the Window top is not equal to window.self (which has the reference to the current window) then if statement gets fired and the message:


The window is not current window!!!!!

is displayed.

« « Connection between Data Model and Data Warehouse
VSAM Structure » »

Author Description

Avatar

Editorial Team at Exforsys is a team of IT Consulting and Training team led by Chandra Vennapoosa.

Free Training

RSSSubscribe 394 Followers
  • Popular
  • Recent
  • JavaScript Math Object

    August 9, 2007 - 0 Comment
  • JavaScript Object Oriented Features

    May 20, 2007 - 0 Comment
  • JavaScript Exception Handling – Part II

    August 2, 2007 - 0 Comment
  • JavaScript Document Object

    July 29, 2007 - 0 Comment
  • JavaScript Iterative Structures – Part I

    July 26, 2007 - 0 Comment
  • JavaScript Browser Objects

    June 13, 2007 - 0 Comment
  • JavaScript OnError Event

    August 4, 2007 - 0 Comment
  • JavaScript Variables

    April 15, 2007 - 0 Comment
  • JavaScript Document Object Properties

    June 13, 2007 - 0 Comment
  • JavaScript Iterative Structures – Part II

    July 27, 2007 - 0 Comment
  • JavaScript Objects

    August 12, 2007 - 0 Comment
  • JavaScript String Object

    August 12, 2007 - 0 Comment
  • JavaScript Date Object

    August 12, 2007 - 0 Comment
  • JavaScript Math Object

    August 9, 2007 - 0 Comment
  • JavaScript Windows Object Properties Part II

    August 9, 2007 - 0 Comment
  • JavaScript Windows Object Properties Part I

    August 8, 2007 - 0 Comment
  • JavaScript Window Object Timeout Methods

    August 8, 2007 - 0 Comment
  • JavaScript Document Object Methods Part II

    August 7, 2007 - 0 Comment
  • JavaScript Document Object Methods Part I

    August 5, 2007 - 0 Comment
  • JavaScript History Object Properties and Methods

    August 5, 2007 - 0 Comment

Exforsys e-Newsletter

ebook
 

Related Articles

  • JavaScript Objects
  • JavaScript String Object
  • JavaScript Date Object
  • JavaScript Math Object
  • JavaScript Windows Object Properties Part II

Latest Articles

  • Project Management Techniques
  • Product Development Best Practices
  • Importance of Quality Data Management
  • How to Maximize Quality Assurance
  • Utilizing Effective Quality Assurance Strategies
  • Sitemap
  • Privacy Policy
  • DMCA
  • Trademark Information
  • Contact Us
© 2023. All Rights Reserved.IT Training and Consulting
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.AcceptReject Read More
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT