我在弄清楚如何访问 Air 中 iframe 中的内容时遇到了很多麻烦。这是我一直在测试的一些示例 jquery 代码。
$(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 是。
<iframe src="http://google.com" id="frame" width="100%" sandboxRoot="http://google.com/" documentRoot="/" name="frame" height="600"></iframe>
上述代码的输出是
null
undefined
正如您所看到的,内容始终为 null、未定义或空字符串。我是否遗漏了一些阻止我访问 iframe 内容的内容?任何建议将不胜感激。
解决方案就在这里http://help.adobe.com/en_US/AIR/1.1/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7f08.html http://help.adobe.com/en_US/AIR/1.1/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7f08.html
这是我如何让它发挥作用的示例。
<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 http://google.com/local)将从文档根目录使用,并将被视为来自同一域(google.com)。
在 iframe.html 中,我可以通过谷歌访问 iframe,就像它来自同一域一样。
我知道必须有办法做到这一点:)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)