Home > Web Front-end > JS Tutorial > jquery implementation code for finding iframe parent page elements_jquery

jquery implementation code for finding iframe parent page elements_jquery

WBOY
Release: 2016-05-16 18:02:53
Original
972 people have browsed it

Parent page code

Copy code The code is as follows:





Untitled Document









iframe page code
Copy code The code is as follows:





Untitled Document

<script> <br>$("body",parent.document).append('hahaha' ); <br></script>


iframe test--@mybest



There is such a record in the jQuery documentation:
jQuery(html, [ownerDocument])
Parameters
html String
HTML used to dynamically create DOM elements Mark string

ownerDocument (optional) Document
Create the document where the DOM element is located


You still need to read more and read the document carefully. It is really the saying: read the book a hundred times , its meaning is self-evident!

------Additional note--------------------------

During testing, I found that chrome could not achieve the above requirements. Later, I saw someone on the Internet pointing out that iframes cannot cross domains. This is one of the problems. Another reason is to put it into a site for testing

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

In this way, chrome will behave normally
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template