Access the content of a nested Iframe

2019-09-06 06:29发布

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.

标签: iframe nested
1条回答
太酷不给撩
2楼-- · 2019-09-06 07:04

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;
查看更多
登录 后发表回答