Parent Page code
Copy 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>
</Head>
<Body>
<Div style = "height: 300px; background-color: # CC9900"> </div>
<Div>
<Iframe src = "test_iframe.html"> </iframe>
</Div>
</Body>
</Html>
Iframe Page code
Copy 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.