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

小云云
Release: 2017-12-29 09:49:25
Original
3878 people have browsed it

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)
Copy after login

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

$(this).contents().find("#suggestBox")
Copy after login

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

parent.method parent.value
Copy after login

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)
Copy after login

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

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

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

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

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

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

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

window.parent.func();
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template