jquery Gets the value of an element of the parent window in the IFRAME

Source: Internet
Author: User

To provide a jquery in the IFRAME to get the parent window of an element of the value implementation, this IFRAME with JS is also similar to the need for friends can refer to.

1. Get the class with the specified IFRAME (testiframe) ID testid in the parent window

$ (window.frames["Testiframe"].document). Find ("#testid"). attr (' class ');

2. Get the class with ID TestID in the parent window in the IFRAME

$ (window.parent.document). Find ("#testid"). attr (' class ');

Of the IFRAME framework:

<iframe src= "test.html" id= "Testiframe" width= "$" height= "frameborder=" "0" scrolling= "Auto" ></iframe >

To release the wording of an IFRAME:

Wrapper.iframeremove = function () {
var frame = $ (frames["Showiframe"]) [0];//showiframe refers to the ID of the IFRAME
$ ("iframe", Tophelper.comwin). attr ("src", "About:blank");
Frame.contentWindow.document.write (");//Empty the contents of the IFRAME
Frame.contentWindow.close ();//Avoid IFRAME memory leaks
Frame.remove ();//delete iframe
}

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.