Jquery: How to make a sub-window's div appear above the parent window

Source: Internet
Author: User

<1> js or jquery to access the frame iframe in the page.
Note: Pages within a frame are not cross-domain! Suppose there are two pages under the same domain.

Assumption: Parent window index.html, iframe with ID subifrm

1. In index.html execute JS direct access to an element in the child window:

document.getElementById (' subifrm '). ContentWindow.document.getElementById (' Test '). style.color= ' Red '

2. Use jquery to access child windows

$ ("#subifrm"). Contents (). Find ("#test"). CSS (' Color ', ' red ');

====================================================================

====================================================================

<2> Interactive operation in a way that combines the DOM approach with the jquery approach
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");

====================================================================

====================================================================

<3> using jquery to manipulate IFRAME

1 of two ifame in the page

<iframe id= "Leftiframe" ></iframe>

<iframe id= "mainiframe></iframe>

<iframe id= "Leftiframe" ></iframe>

<iframe id= "mainiframe></iframe>

Leftiframe in jquery changes the SRC code of Mainiframe:

1

$ ("#mainframe", Parent.document.body). attr ("src", "")

2, if the content has an ID of mainiframe ifame

<iframe id= "Mainifame" ></ifame>

<iframe id= "Mainifame" ></ifame>

Ifame contains a Someid

<div id=" SomeID " >you want to get this &NBSP; content </div>   

<div id= "Someid" >you want to get this content</div>

Get Someid's content

$ ("#mainiframe"). Contents (). Find ("Someid"). html (); or $ ("#mainiframe"). Contains (). Find ("Someid"). Text ();

$ ("#mainiframe"). Contents (). Find ("Someid"). html ();  or $ ("#mainiframe"). Contains (). Find ("Someid"). Text ();

$ ("#mainiframe"). Contents (). Find ("Someid"). html (); or $ ("#mainiframe"). Contains (). Find ("Someid"). Text ();

2, as shown above
Leftiframe in jquery operations Mainiframe content Someid content

$ ("#mainframe", Parent.document.body). Contents (). Find ("Someid"). html ();  or $ ("#mainframe", Parent.document.body). Contents (). Find ("Someid"). Val ();

Source


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.