Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

8.4. Summary

For various reasons, having a frame-based web site can prove very useful. Therefore, you need to be able to create JavaScript that can interact with frames and with the documents and code within those frames.

  • You saw that an advantage of frames is that, by putting all of your general functions in a single frame, you can create a JavaScript code module that all of your web site can use.

  • You saw that the key to coding with frames is getting a reference to the window objects of other frames. You saw two ways of accessing frames higher in the hierarchy, using the window object's parent property and its top property.

  • The parent property returns the window object that contains the current window object, which will be the page containing the frameset that created the window. The top property returns the window object of the window containing all the other frames.

  • Each frame in a frameset can be accessed through three methods. One is to use the name of the frame. The second is to use the frames collection and specify the index of the frame. The third way is to access the frame by its name in the frames collection — for example, parent.frames.frameName. This the safest way, because it avoids any collision with global variables.

  • If the frame you want to access is defined in another window, you need the parent or top property to get a reference to the window object defining that frame, and then you must specify the name or position in the frames collection.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial