How to operate parent page elements on iframe subpages

Source: Internet
Author: User

Iframe pages are embedded in the parent page. Generally, iframe pages are used by default for relevant actions in the iframe, which does not affect the parent page. What should I do if I need to operate the elements of the parent page on the Child pages of iframe?

To operate the parent page element on the iframe sub-page, you need to know the following two points:

(1) The iframe subpage and parent page must belong to the same domain.

(2) The object method for retrieving the parent page from the iframe page is parent.

Example:

<Body>
<Div id = "test"> </div>
<Iframe src = "http://www.phpernote.com/javascript-function/272.html"> </iframe>
</Body>

In the http://www.phpernote.com/javascript-function/272.html page, add the "iframe child Page Operation parent page element" to the content of the id = "test" element of the parent page as follows:

Parent.doc ument. getElementById ('map _ position'). innerHTML = 'iframe sub-page operation parent page element ';

Similarly, if you need to refresh the parent page on the Child page, you can use: parent. location. reload ();

Articles you may be interested in
  • How does jquery operate on iframe parent page elements?
  • Optimization operations on a single page-Details determine the ranking
  • How to control the order of page content loading
  • How to optimize website pages and increase webpage loading speed
  • Prohibit web page right-click, copy, save as, View Source file and other functions to implement web page source code protection
  • How to set the jump wait time for the thinkphp page Jump (successerror)
  • Js address bar special effects (display the size of all images with links on the page and view the height of the current browser)
  • Three solutions for ineffective page refresh caused by Js, css, and images cached on webpages

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.