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;