Implementation Code of jquery to find IFRAME parent page elements

Source: Internet
Author: User

Parent page Code Copy code The Code is as follows: <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> untitled document </title>
</Head>
<Body>
<Div style = "height: 300px; Background-color: # cc9900"> </div>
<Div>
<IFRAME src = "test_iframe.html"> </iframe>
</Div>
</Body>
</Html>

IFRAME Page codeCopy codeThe Code is as follows: <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> untitled document </title>
<SCRIPT src = "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"> </SCRIPT>
<SCRIPT>
$ ("Body", parent.doc ument). append ('hahahaha ');
</SCRIPT>
</Head>
<Body>
IFRAME test -- @ mybest
</Body>
</Html>

There is such a record in the jquery document:
Jquery (HTML, [ownerdocument])
Parameters
HTML string
HTML Tag string used to dynamically create DOM elements

Ownerdocument (optional) Document
Document where the DOM element is created

I still want to read more and read more documents. what is it really like: I read a book a hundred times!

------ Note --------------------------

During the test, I found that Chrome could not meet the above requirements. Later I saw that IFRAME cannot be cross-origin, which is one of the problems. Another reason is to put it in a site for testing.

For example, http: // localhost: 8087/test.html

In this way, chrome will be normal.

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.