在Adobe AIR访问一个iframe的内容 [英] Accessing an iframe's contents in Adobe Air
问题描述
我一直有很多麻烦搞清楚如何,我可以在空气中的iframe中访问的内容。下面是一些例子jQuery的code,我一直在测试使用。
I have been having a lot of trouble figuring out how I can access the content within an iframe in Air. Here is some example jquery code that I have been testing with.
$(document).ready(function(){
$("#frame").ready(function(){
air.trace($("#frame").contents().find("body").html());
air.trace(window.frames["frame"].innerHTML);
air.trace(document.getElementById("frame").innerHTML);
});
});
我使用的是iframe的
The iframe I am using is.
<iframe src="http://google.com" id="frame" width="100%" sandboxRoot="http://google.com/" documentRoot="/" name="frame" height="600"></iframe>
从上面的code的输出为
The output from the above code is
null
undefined
正如你所看到的内容始终为null,未定义或空字符串。我缺少的东西是$ P $访问iframe的内容pventing我吗?任何建议,将不胜AP preciated。
As you can see the contents are always either null, undefined or an empty string. Am I missing something that is preventing me from accessing the content of the iframe? Any suggestions would be greatly appreciated.
推荐答案
解决的办法是这里<一个href="http://help.adobe.com/en_US/AIR/1.1/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7f08.html" rel="nofollow">http://help.adobe.com/en_US/AIR/1.1/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7f08.html
下面是我得到了它的工作的一个例子。
Here is an example of how I got it working.
<iframe src="http://google.com/local/iframe.html" id="frame" width="100%" sandboxRoot="http://google.com/local/" documentRoot="app:/" name="frame" height="600"></iframe>
从sandboxRoot请求任何(例如 http://google.com/local 的)将被从用于文档根目录,将被视为是从同一个域(google.com)。
Anything requested from the sandboxRoot(e.g. http://google.com/local) will be used from the document root and will be treated as if it is from the same domain(google.com).
在iframe.html我可以访问iframe来谷歌就好像它是来自同一个域。
In iframe.html I can access the iframe to google just as if it were from the same domain.
我知道必须有一个办法做到这一点:)
I knew there had to be a way to do this :)
这篇关于在Adobe AIR访问一个iframe的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!