Browser window can be split into many parts called frames. Each part behaves as a separate window and can load separate documents. Reloading and navigation of one frame does not affect other frames. Each frame has a separate window object and window object has a name property containing name of the frame. If there are multiple frames in a webpage the multiple window objects are indexed in frame collection by both number and name of the frame. The
window.frames syntax lists the sub-frames of the current window (aka iframes) as array-like object.
Following list shows some of the possibilities when using the window object:
- frameList = window.frames; - returns the frame list.
- window.frames - access frames by number.
- window.frames[‘iframe_name’] - access iframe by name.
- window.frames[index].location- changes the webpage in the ‘index’ position to the location assigned.
- window.length – gives the number of iframe elements in the current window.
Example of using window object in browser-object-model