[JavaScript]
[Previous page] [Section contents page] [Next page]
Window Location Object

The location object is important enough to devote a separate page to, because it can be used not only to obtain information about the document in any frame currently open, but also to set the document for any frame. When you set a location, you are creating a link that may be activated after some specified time, or when some event (like a mouse-click in a particular location) takes place. Here are some samples of locations and location properties, along with the values returned by the browser you are using.

Note that you can also get (or set) the location object and its properties for any frame that is currently defined (i.e. open). Frames are numbered in the order of their creation, starting with 0. The following are examples of location properties for frames. In this case, I will not show you what these properties actually return from the browser, because that would produce a script error if this page were loaded outside of its intended frameset.

  • parent.location
  • parent.frames[0].location
  • parent.frames[1].location
  • top.location
  • top.frames[0].location

Note that top and parent here work slightly differently here than they do in HTML. Parent and Top will be identical unless the they represent framesets written in different HTML files, and thus having different locations. So that in the following frameset definition:

<frameset cols="100%" rows="25,*" border="0">
	<frame name="Header" src="../glossary/menu.html" scrolling="no">
	<frameset rows="100%" cols="150,*" border="0">
		<frame src="toc-index.html" name="toc">
		<frame src="js_000.html" name="display">
	</frameset>
</frameset>	
	

It might seem here that the file js_000.html has a different parent frame than the file menu.html, but for JavaScript they both have the same parent. However, if the frameset that splits the lower row into two columns were defined in a separate page, called by the SRC value for the second frame in the outer set, then the parents would be different.

[Previous page] [Section contents page] [Next page]