Access the content of a nested Iframe

♀尐吖头ヾ 提交于 2019-12-12 02:17:25

问题


I am creating an applicaiton where I want to access the content of nestend iframe. Say I have a page test.aspx Now there is an iframe say iframe1. and the content of this iframe is another iframe. say iframe2 So its a nested iframe. Now I want to access the content of the iframe2. How we can access the content of this 2nd iframe as I have to search some text in the 2nd iframe. I want to access the iframe with javascript or jquery only.


回答1:


Finally I found the solution.

document.getElementById('iframe1').contentWindow.document.getElementById('iframe2').contentWindow;

and for the innerHTML use

frameElement.contentDocument.activeElement

var iframeFound = document.getElementById('iframe1').contentWindow.document.getElementById('iframe2').contentWindow;
         var   ifrme = iframeFound.frameElement.contentDocument.activeElement;


来源:https://stackoverflow.com/questions/29910766/access-the-content-of-a-nested-iframe

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!