Practical operation of IFRAME _javascript techniques

Source: Internet
Author: User
The iframe height is set to the child page height
Copy Code code as follows:

Need to use jquery
$ (document). Ready (function () {
Parent.document.getElementById ("Ifpage"). Style.height = document.body.scrollHeight + "px";
});

IFRAME highly adaptive to parent page
Copy Code code as follows:

Need to use jquery
$ (window). Resize (function () {
var webheight = document.body.clientheight-x; X is the amount of height that needs to be subtracted, such as the height of the top navigation
$ ("#ifPage"). attr ("style", "Height:" + webheight + "px;");
});
$ (window). Load (function () {
var webheight = document.body.clientheight-105;
$ ("#ifPage"). attr ("style", "Height:" + webheight + "px;");
});

Passing elements between parent-child pages
Parent page Gets the data from the child page, JS code:
Copy Code code as follows:

Gets an object based on the ID of the IFRAME
var i1 = window.frames[' Iframeid '];
var iframe =window.frames[0]; you can also
Gets the element value in the IFRAME
var Val=i1.document.getelementbyid ("T1"). Value

Sub-page Gets the data in the parent page, JS code:
Copy Code code as follows:

var val = parent.document.getElementById ("Txt1");

Sub-page and sub-page transfer between, JS code:
Copy Code code as follows:

var i1 = parent.window.frames[' Iframeid '];
var val = i1.document.getElementById ("Text1"). Value;

Refreshing the parent page
Copy Code code as follows:

function Parentreload () {window.parent.location.reload ();}

Reload Child pages
Copy Code code as follows:

Iframe. attributes["SRC"] = "itemtqeditorpage.aspx";

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.