Home >Web Front-end >JS Tutorial >Summary of methods for using JQuery to operate iframe parent pages and child pages

Summary of methods for using JQuery to operate iframe parent pages and child pages

小云云
小云云Original
2017-12-29 09:49:253831browse

iframe is often used in compound documents. Using jquery to operate iframe can greatly improve efficiency. This article mainly shares with you some records about simply using JQUERY to operate IFRAME. This can also be achieved using pure JS. Not much to say below, let’s take a look at the detailed introduction. This article mainly introduces you to the relevant information about using JQuery to operate the elements and methods of iframe parent pages and sub-pages. The article introduces it in great detail through sample codes. It has certain reference learning value for everyone's study or work. Friends who need it Let’s learn with the editor below.

First, how to find the elements of the parent page in the iframe:

$('#id', window.parent.document)

Second, how to get the elements in the iframe in the parent page:

$(this).contents().find("#suggestBox")

Third, Call the methods and variables defined in the parent page in the iframe:

parent.method parent.value

JQUERY, JS method of calling the IFRAME parent window and child window elements

1. jquery gets the parent page element in the iframe child page The code is as follows:

$("#objid", parent.document)

2. jquery gets the element code of the iframe subpage from the parent page as follows:

$("#objid",document.frames('iframename').document)

3.js The code for getting the parent page element from the iframe subpage is as follows:

indow.parent.document.getElementByIdx_x("元素id");

4.js The code to obtain iframe subpage elements from the parent page is as follows:

window.frames["iframe_ID"].document.getElementByIdx_x("元素id");

5. Call the parent class function in the subclass iframe:

window.parent.func();

Related recommendations:

Examples of methods of using iframe elements in vue components

A brief analysis of the navigation window inside the Iframe web page

How to use the iframe attribute

The above is the detailed content of Summary of methods for using JQuery to operate iframe parent pages and child pages. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn