Window.frames of JavaScript host objects

Source: Internet
Author: User

The Window.frames property is a collection of all frames for the current page. Note that there is no frame and IFRAME to make a distinction. Also, the Window.frames property always exists, regardless of the frame in which the page exists, and always points to the Window object itself.

// true;

Suppose we have an IFRAME element in our page:

<name= "MyFrame"  src= "hello.html"/>

We can see if the frame element exists in the page by checking its Length property.

Frames.length; 1

If you want to access the window object of an IFRAME element, you can choose either of the following methods:

Window.frames[0];window.frames[0].window;window frames[0].window.frames;frames[0  ].window;frames[0];

From the parent page, we can access the properties of the child frame element. For example, you can have an overload of the IFRAME element in the following way.

Frames[0].window.location.reload ();

In the same way, we can access the parent page through child elements.

frames[0].parent = = = Window

We can access the topmost page through a property called the top:

// true // true // true;

In addition, there is a self property, which is essentially the same as window.

Self = = = window; True
Frames[0].self = = Frames[0].window; True

If the frame element has the name attribute, we can drop the index and then access the frame by the value of the Name property;

window.frames[' myframe '] = = = Window.frames[0];  // true

Or it can also:

// true

Window.frames of JavaScript host objects

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.