spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / programming / prof_java / 1 To page 1To page 2To page 3To page 4current page
[previous]

Sr. Web Developer
Professional Technical Resources
US-OR-Portland

Justtechjobs.com Post A Job | Post A Resume
Developer News
Mandrake Linux Founder Back, Virtually
Amazon: We're a Technology Company
Sun Expands MySQL With Closed Source

Professional JavaScript for Web Developers: JavaScript in the Browser, Pt. 1

Another instance of the window object is called parent. The parent object is used with framesets that load files that are also framesets. Suppose the file named frameset1.htm contains this code:

Now what if there is also a file named anotherframeset.htm containing this code?

When the first file, frameset1.htm, is loaded into the browser, it loads anotherframeset.htm into
rightFrame. If code is written in redFrame (or blueFrame), the parent object points to rightFrame in
frameset1.htm. If, however, code is written in topFrame, the parent object actually points to top
because the browser window itself is considered the parent of any top-level frameset.

Figure 5-5 proves this fact by accessing the window object’s name property, which stores the name of the frame (but will always be blank for top).

One more global window pointer, called self, is always equal to window (yes, a bit redundant, but it’s included as a better fit with parent. It clarifies that you are not talking about the frame’s parent but the frame itself.)

If there are no frames in the page, window and self are equal to top and the frames collection has a length of 0.

It is also possible to chain references to window objects together, such as parent.parent.frames [“topFrame”], although this is generally frowned upon because any change in the frame structure results in code errors.

Manipulating windows

As mentioned previously, the window object is useful to manipulate browser windows (and frames) which means as a developer, you are able to move and resize browser windows. Four methods are available to accomplish this:

For example:

Suppose you went through all this trouble to change the size and position of a window, but you didn’t keep track of the changes. Now you need to figure out where on the screen the window is located and what its dimensions are. This is where a lack of standards causes problems.

So the question becomes one of understanding the browsers your users have.

Even though moving and resizing browser windows is a cool trick, it should be used sparingly. Moving and resizing windows has a jarring effect on users and for this reason is usually avoided in professional Web sites and Web applications.

Reproduced from "Professional JavaScript for Web Developers" by permission of WROX. ISBN 0764579088, copyright 2005. All rights reserved. See WROX for more information.

home / programming / prof_java / 1 To page 1To page 2To page 3To page 4current page
[previous]

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Working with the DOM Stylesheets Collection · Administering RBAC in PHP 5 CMS Framework · xref: Automatic Cross Referencing Script
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Combine BottomCount() with Other MDX Functions to Add Sophistication · Creating a Daemon with Python · The Coming Voice-over-WiMAX Revolution

Created: March 27 2003
Revised: June 20, 2005

URL: http://webreference.com/programming/prof_java/1