How does jquery operate on iframe parent page elements?

Source: Internet
Author: User

You should be very clear about the javascript method for operating iframe parent page elements, the following describes how to use jquery to find and operate iframe parent page elements. Example:

<Html> 

The following is the iframe.html Page code:

<Html> 

In addition, because iframe cannot be cross-origin, if you open the above files directly, Some browsers may not work. In this case, you can upload the above two files to a local or remote server to see the effect.

In addition, there are several notes for javascript operations on iframe objects:

To operate the dom of the parent window, js in iframe must understand several objects:

Parent is the parent window (if the window is a top-level window, parent = self = top ),

Top is the top parent window (some windows have several layers of frameset or iframe ),

Self is the current window (equivalent window ),

Opener is the window that opens the current window using the open method;

In this way, js in iframe can obtain the window objects of the parent window through the parent and top objects to operate the dom of the parent window. For example:

Parent.doc ument. getElementById ("dom ID ");

Parent and top can also call the js method of the parent window. For example, if getIFrameDOM (iID) is a method of the parent window, you can use parent in iframe. getIFrameDOM ("wIframeA") to call the getIFrameDOM (iID) method of the parent window.

Articles you may be interested in
  • How to operate parent page elements on iframe subpages
  • Js address bar special effects (display the size of all images with links on the page and view the height of the current browser)
  • How to control the order of page content loading
  • Js operation cookie, js reading cookie, js setting cookie, js deleting cookie Summary
  • Functions related to cookie operations in JavaScript
  • Summary of the methods for refreshing iframe using javascript
  • Jquery checks whether the page has been loaded with the jquery File
  • JavaScript to print pages

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.