Iframe practical operations

Source: Internet
Author: User

Iframe height is set to the height of the Child page
Copy codeThe Code is as follows:
// Jquery is required
$ (Document). ready (function (){
Parent.doc ument. getElementById ("ifPage"). style. height = document. body. scrollHeight + "px ";
});

Iframe highly adaptive to the parent page
Copy codeThe Code is as follows:
// Jquery is required
$ (Window). resize (function (){
Var webheight = document. body. clientHeight-X; // X indicates the height to be subtracted, for example, the height of the top navigation bar.
$ ("# IfPage"). attr ("style", "height:" + webheight + "px ;");
});
$ (Window). load (function (){
Var webheight = document. body. clientHeight-105;
$ ("# IfPage"). attr ("style", "height:" + webheight + "px ;");
});

Transfer elements between parent and child pages
The parent page obtains the data in the Child page. JS code:
Copy codeThe Code is as follows:
// Obtain the object based on the iframe id
Var i1 = window. frames ['iframeid'];
// Var iframe = window. frames [0]; or
// Obtain the element value in iframe
Var valpolici1.doc ument. getElementById ("t1"). value

The child page obtains data from the parent page. JS code:
Copy codeThe Code is as follows:
Var val = parent.doc ument. getElementById ("txt1 ");

Transmission between subpages and subpages. JS code:
Copy codeThe Code is as follows:
Var i1 = parent. window. frames ['iframeid'];
Var val = i1.document. getElementById ("text1"). value;

Refresh parent page
Copy codeThe Code is as follows:
Function parentReload () {window. parent. location. reload ();}

Reload the subpage
Copy codeThe Code is as follows:
Iframe. Attributes ["Src"] = "ItemTQEditorPage. aspx ";

Related Article

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.