Home > Web Front-end > JS Tutorial > Detailed explanation of the case of JS getting the iframe of the parent window and child window

Detailed explanation of the case of JS getting the iframe of the parent window and child window

php中世界最好的语言
Release: 2018-04-26 15:38:28
Original
1881 people have browsed it

This time I will bring you a detailed explanation of the case of JS getting the iframe of the parent window and the child window. What are the precautions for JS getting the iframe of the parent window and the child window? The following is a practical case, let's take a look. .

In web development, iframes are often used. It is inevitable that you need to use elements in the iframe in the parent window, or use elements of the parent window in the iframe

frame

js

Get the elements in the iframe in the parent window

1,

格式:window.frames["iframe的name值"].document.getElementByIdx_x("iframe中控件的ID").click();
实例:window.frames["ifm"].document.getElementByIdx_x("btnOk").click();
Copy after login

2,

Format:

var obj=document.getElementByIdx_x("iframe的name").contentWindow;
var ifmObj=obj.document.getElementByIdx_x("iframe中控件的ID");
Copy after login

ifmObj.click();

Instance:

var obj=document.getElementByIdx_x("ifm").contentWindow;
var ifmObj=obj.document.getElementByIdx_x("btnOk");
ifmObj.click();
Copy after login

Get the elements of the parent window in iframe

格式:window.parent.document.getElementByIdx_x("父窗口的元素ID").click();
实例:window.parent.document.getElementByIdx_x("btnOk").click();
Copy after login

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to the php Chinese website

Others related articles!

Recommended reading:

jquery ajax makes it adaptive to height when applying iframe

jquery js calls the iframe parent window with Detailed explanation of sub-window steps

Jquery to obtain the Dom element in the iframe page (with code)

The above is the detailed content of Detailed explanation of the case of JS getting the iframe of the parent window and child window. 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