How the IFRAME child page invokes the parent page JavaScript function
Today encountered an IFRAME child page called the parent page JS function requirements, the solution is very simple, but in the Chrome browser encountered a small problem. By the way, the parent page of the IFRAME calls the child page JavaScript function method, spare!
1. IFRAME Child page Call parent page JS function
The child page calls the parent page function just to write on window.praent. For example, invoking the A () function is written as:
WINDOW.PRAENT.A ();
But I found this method invalid in Chrome! For a long while to understand, in the chrome 5+, Window.parent cannot run in the FILE://protocol, but after the release of http://protocol can be run. This method supports IE, Firefox browser.
2, the IFRAME Child parent page called the child page JS function
This is a little more complicated, the following methods support IE and Firefox browser:
document.getElementById (' Ifrtest '). contentwindow.b ();
Note: Ifrtest is the id,b () of the IFRAME frame as a sub-page JS function. The Contentwindow property is the window object of the specified frame or IFRAME, which can be omitted under IE.