JavaScript
  Home arrow JavaScript arrow The Window Phase of Chrys`s Approach to AC...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

The Window Phase of Chrys`s Approach to ACP
By: Chrysanthus Forcha
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2009-08-28

    Table of Contents:
  • The Window Phase of Chrys`s Approach to ACP
  • Examples of Window Properties and Methods
  • Window name Property
  • Examples of Window Methods

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    The Window Phase of Chrys`s Approach to ACP


    (Page 1 of 4 )

    The Window Phase of Chrys’s Approach to ACP is similar to the Document Phase. However, instead of having HTML documents (pages) opened within one browser window, you open both browser windows. This is the ninth part of a twelve-part series on Active Client Pages.

    Each of the windows opened in the Window Phase can have documents of the document phase of Chrys's Approach. As you can see, this approach incorporates the document phase of Chrys's Approach, the script approach and the Ajax approach.

    Window Object

    The Window object is the top-level object in the JavaScript hierarchy. The Window object represents a browser window. A Window object is created automatically with every instance of a <body> or <frameset> tag. However, we do not use frameset in this phase.

    Window Object Properties we need

    Property

    Description

    closed

    Returns whether or not a window has been closed.

    defaultStatus

    Sets or returns the default text in the status bar of the window.

    name

    Sets or returns the name of the window.

    opener

    Returns a reference to the window that created the window.

    self

    Returns a reference to the current window.

    status

    Sets the text in the status bar of a window.

    top

    Returns the topmost ancestor window.

    Window Object Methods we need

    Method

    Description

    blur()

    Removes focus from the current window.

    focus()

    Sets focus to the current window.

    open()

    Opens a new browser window.

    close()

    Closes the current window.


    There is more to the open() method than what I have stated. We saw a bit of the extra features in the previous part of the series. Let us look at the syntax and parameter in more detail.

    The Window open() Method

    Definition and Usage

    The open() method is used to open a new browser window.

    Syntax

    window.open(URL,name,specs,replace)


    Parameter

    Description

    URL

    Optional. Specifies the URL of the page to open. If no URL is specified, a new window with about:blank is opened.

    name

    Optional. Specifies the target attribute or the name of the window. The following values are supported:

    • _blank - URL is loaded into a new window. This is the default.

    • _parent - URL is loaded into the parent frame.

    • _self - URL replaces the current page.

    • _top - URL replaces any framesets that may be loaded.

    • name - The name of the window.

    specs

    Optional. A comma-separated list of items. The following values are supported:


    replace

    Optional. Specifies whether the URL creates a new entry or replaces the current entry in the history list. The following values are supported:

    • true - URL replaces the current document in the history list.

    • false - URL creates a new entry in the history list.



    Window open() Method Example

    The following example opens an about:blank page in a new browser window:


    <html>

    <body>

    <script type = "text/javascript">

    myWindow = window.open('','','width=200,height=100')

    myWindow.document.write("This is 'myWindow'")

    </script>

    </body>

    </html>


    The second statement in the script opens the window. The expression to the right hand side of the assignment operator returns a reference. This reference is held by the myWindow variable, and used to write content to the opened window. As we see in the last statement in the script, this reference can take the document property, which can take the write() method.

    Note: the window object does not have the write() method. It is the document object that has the write() method. We have to distinguish between the window open() method and the document open() method which we have seen before in this series.

    The document open() method opens an output stream which can result into a document. A document is a page in the browser window. A window is the browser window itself.

    Just after using the document open() method, you can use the document write() method to write HTML contents to the output stream. You then use the document close() method to close the output stream, thereby creating a newly-opened document, which would be in the same browser window as the previous document (page).

    On the other hand, the window open() method opens a new browser window, with its own bars (title, menu and tool bars), separated from the previous window -- and that is it; you do not have to close this opening process. However, you can use the reference to the opened window (for example, myWindow in the above case); you can write to it. The window object has a close() method, but, this method does not close the opening process; it removes the window from the screen.

    You can try the above example; save it as an HTML file and then open it.

    More JavaScript Articles
    More By Chrysanthus Forcha


     

    JAVASCRIPT ARTICLES

    - Comparing Fields and Customizing Error Messa...
    - Checking Numbers and File Extensions with jQ...
    - Validating Digits and Dates with jQuery`s Va...
    - Validating Ranges, Emails, and URLs with jQu...
    - More Uses for the jQuery Tooltip Plug-in`s b...
    - Building Image-Based Tooltips with the jQuer...
    - Using the jQuery Tooltip Plug-in`s bodyHandl...
    - Using Rangelength, Min and Max with the Vali...
    - Using Minlength and Maxlength with the Valid...
    - Modifying Tooltip Coordinates with the jQuer...
    - Applying a Fade Out Effect with the jQuery T...
    - Tracking Mouse Movements with the jQuery Too...
    - Checking Online Forms with the Validator jQu...
    - Nested JavaScript Functions as Objects
    - The jQuery Tooltip Plug-in







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek