Home >
Web Front-end >
JS Tutorial >
Specific implementation of mutual acquisition of variables and element objects between parent element and child iframe_javascript skills
Specific implementation of mutual acquisition of variables and element objects between parent element and child iframe_javascript skills
alert(window.parent.count); //Get the js variable in the parent alert($("#username", window.parent.document ));//Get the jQuery object in the parent alert(window.parent.document.getElementByIdx_x('username'));//Get the DOM object in the parent
alert(document.iframeName.count);//Get the sub-iframe js variable alert($(window.frames["iframeName"].document).contents().find("#username"));//Get the jQuery object in the sub-iframe alert($(" #username",document.frames("iframeName").document));//Get the jQuery object in the sub-iframe alert(window.document.getElementById('iframeId').contentWindow.document.getElementByIdx_x('username' ));//Get the DOM object in the child iframe
Collect some examples on the Internet: Use jQuery to get the parent in the IFRAME The value of a certain element in the window has to be realized by combining the DOM method and the jquery method
1. Select all the radio buttons in the IFRAME in the parent window $(window. frames["iframe1"].document).find("input:radio").attr("checked","true"); 2. Select all radio buttons in the parent window in IFRAME $(window.parent.document).find("input:radio").attr("checked","true"); If the parent window wants to get the Iframe in the IFrame, just add a frames child. For example: $(window.frames["iframe1"].frames["iframe2"].document).find("input:radio").attr("checked","true"); 3. Call the method (FRAME) of another child window in the parent window in the child window: parent.frames["Main"].Fun(); Note: It is recommended to use [] to compare like this Compatible with multiple browsers, ()Firefox/Sogou/Google are not compatible.
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