You should be very clear about the javascript method for operating iframe parent page elements, the following describes how to use jquery to find and operate iframe parent page elements. Example:
<Html>
The following is the iframe.html Page code:
<Html>
In addition, because iframe cannot be cross-origin, if you open the above files directly, Some browsers may not work. In this case, you can upload the above two files to a local or remote server to see the effect.
In addition, there are several notes for javascript operations on iframe objects:
To operate the dom of the parent window, js in iframe must understand several objects:
Parent is the parent window (if the window is a top-level window, parent = self = top ),
Top is the top parent window (some windows have several layers of frameset or iframe ),
Self is the current window (equivalent window ),
Opener is the window that opens the current window using the open method;
In this way, js in iframe can obtain the window objects of the parent window through the parent and top objects to operate the dom of the parent window. For example:
Parent.doc ument. getElementById ("dom ID ");
Parent and top can also call the js method of the parent window. For example, if getIFrameDOM (iID) is a method of the parent window, you can use parent in iframe. getIFrameDOM ("wIframeA") to call the getIFrameDOM (iID) method of the parent window.
Articles you may be interested in
- How to operate parent page elements on iframe subpages
- Js address bar special effects (display the size of all images with links on the page and view the height of the current browser)
- How to control the order of page content loading
- Js operation cookie, js reading cookie, js setting cookie, js deleting cookie Summary
- Functions related to cookie operations in JavaScript
- Summary of the methods for refreshing iframe using javascript
- Jquery checks whether the page has been loaded with the jquery File
- JavaScript to print pages