|
Free Open Book
Sams Teach Yourself JavaScript in 24 Hours |
Working with FramesBrowsers also support frames, which enable you to divide the browser window into multiple panes. Each frame can contain a separate URL or the output of a script. Using JavaScript Objects for FramesWhen a window contains multiple frames, each frame is represented in JavaScript by a frame object. This object is equivalent to a window object, but it is used for dealing specifically with that frame. The frame object's name is the same as the NAME attribute you give it in the <frame> tag. Remember the window and self keywords, which refer to the current window? When you are using frames, these keywords refer to the current frame instead. Another keyword, parent, enables you to refer to the main window. Each frame object in a window is a child of the parent window object. Suppose you define a set of frames using the following HTML: <frameset ROWS="*,*" COLS="*,*"> <frame NAME="topleft" SRC="topleft.htm"> <frame NAME="topright" SRC="topright.htm"> <frame NAME="bottomleft" SRC="botleft.htm"> <frame NAME="bottomright" SRC="botright.htm"> </frameset> This simply divides the window into quarters. If you have a JavaScript program in the topleft.htm file, it would refer to the other windows as parent.topright, parent.bottomleft, and so on. The keywords window and self would refer to the topleft frame. By the Way If you use nested framesets, things are a bit more complicated. window still represents the current frame, parent represents the frameset containing the current frame, and top represents the main frameset that contains all the others. The frames ArrayRather than referring to frames in a document by name, you can use the frames array. This array stores information about each of the frames in the document. The frames are indexed starting with zero and beginning with the first <frame> tag in the frameset document. For example, you could refer to the frames defined in the previous example using array references:
You can refer to a frame using either method interchangeably, and depending on your application, you should use the most convenient method. For example, a document with 10 frames would probably be easier to use by number, but a simple two-frame document is easier to use if the frames have meaningful names.
|
Main Menu |
| 500 Juegos Gratis | 500 Giochi Gratis | 500 Jeux Gratuits | 500 Jogos Gratis | 500 Kostenlose Spiele |