jquery operation FRAME (iFrame)

Source: Internet
Author: User

I didn't find a good way.
Had to use the DOM method and the jquery method to implement the way

1. Manipulate all the radio buttons in the selected IFrame in the parent window
$ (window.frames["iframe1"].document). Find ("input[@type = ' Radio ']"). attr ("Checked", "true");

2. Action in the IFRAME Select all the radio buttons in the parent window
$ (window.parent.document). Find ("input[@type = ' Radio ']"). attr ("Checked", "true");

IFrame frame: <iframe src= "test.html" id= "iframe1" width= "" height= "" "frameborder=" 0 "scrolling=" Auto "></ Iframe>

IE7 test by going back, you try it yourself.
Just to add a little bit of Google.

I beat my head against this wall for quite some time.

Try this:
$ ("#myid", top.document);
The top.document tells the selector to target the myID element which
exists in the topmost document (your parent page). In order for this
To work, jquery must being loaded in the file which is viewed through the
Iframe.

My Code
$ (' #parentElem ', top.document). Append (' <div class= "Imgbox" id= "Imgbox" ></div>");

Didn't the UPC say?
1. Manipulate all the radio buttons in the selected IFrame in the parent window
$ (window.frames["iframe1"].document). Find ("input[@type = ' Radio ']"). attr ("Checked", "true");

The choice of ID is still using the Find method
$ (window.frames["iframe1"].document). Find ("#id")

The actual method on the upper floor is essentially a call to the Find method parent form within the JQ method (right) for Ifram's iddocument.frames["right"].expand (); parent form: parented;

Subform: Opener; (Window.opener.reload ();)

The above are all online pick up, the following supplement is very important:

As you might have noticed, the top-down approach to selector is to look up the subordinate window from the parent window (including the window created by the IFRAME), and if we want to go from a subordinate window, For example, to find the parentnode of an iframe through the window in the IFRAME, you can:

var parentframe=null;
if (window!=window.top) {parentframe=window.frameelement.name};

Down you can direct $ (...)

Of course, we don't need to do this when there is only one iframe in a topwindow, but this is useful when several IFRAME exist.

jquery Action Frame (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.