访问嵌套iframe的内容 [英] Access the content of a nested Iframe

查看:119
本文介绍了访问嵌套iframe的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个应用程序,我想在该应用程序中访问nestend iframe的内容. 说我有一个页面test.aspx 现在有一个iframe,说是iframe1.而该iframe的内容是另一个iframe.说iframe2 因此,它是一个嵌套的iframe. 现在,我要访问iframe2的内容. 我必须在第二iframe中搜索一些文本,才能访问第二iframe的内容. 我只想使用javascript或jquery访问iframe.

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.

推荐答案

最后我找到了解决方案.

Finally I found the solution.

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

和供innerHTML使用

and for the innerHTML use

frameElement.contentDocument.activeElement

frameElement.contentDocument.activeElement

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

这篇关于访问嵌套iframe的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆