Home arrow JavaScript arrow The Window Phase of Chrys`s Approach to ACP
JAVASCRIPT

The Window Phase of Chrys`s Approach to ACP


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.

Author Info:
By: Chrysanthus Forcha
Rating: 5 stars5 stars5 stars5 stars5 stars / 1
August 28, 2009
TABLE OF CONTENTS:
  1. · The Window Phase of Chrys`s Approach to ACP
  2. · Examples of Window Properties and Methods
  3. · Window name Property
  4. · Examples of Window Methods

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
The Window Phase of Chrys`s Approach to ACP
(Page 1 of 4 )

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.


blog comments powered by Disqus
JAVASCRIPT ARTICLES

- More Top jQuery Plugins for Menus
- Top jQuery Tutorials for Beginners
- New UI Framework and SDK for JavaScript Rele...
- JavaScript OpenPGP Tool, Node.js 0.6.3 Avail...
- Yahoo Releases Cocktails Language and Develo...
- Customizing jQuery Slideshows: Dynamic Contr...
- Customizing jQuery Slideshows: the animate()...
- Customizing jQuery Slideshows: slideUp() and...
- Customizing jQuery Slideshows: hide() and sh...
- Web Workers: Performing Calculations in Para...
- More Top JavaScript Frameworks and Libraries
- More Dynamic jQuery Styling Techniques
- The Top JavaScript Libraries
- The Top JavaScript Frameworks
- Dynamic jQuery Styling

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 6 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials