相关链接:
我有一个部署为 Web 应用程序的 Google Apps 脚本项目,我试图在
<iframe>
. 中显示
加载框架时,框架内 HTML 内容上的链接是可点击的,并产生预期的更新 HTML 内容。单击另一个链接(从第 2 页到第 3 页)会生成一个空白的 HTML 正文。
我发现,当您单击链接或使用像
window.location=
或window.open(url,'_self')
这样的方法时,它会在现有的iframe中打开另一组嵌套的iframe。
这个:
<iframe id="sandboxFrame">
<iframe id="userHtmlFrame">
<!-- my web app html here -->
</iframe>
</iframe>
变成这样:
<iframe id="sandboxFrame">
<iframe id="userHtmlFrame">
<iframe id="sandboxFrame">
<iframe id="userHtmlFrame">
<!-- my web app html here -->
</iframe>
</iframe>
</iframe>
</iframe>
奇怪的是,第一次它仍然显示正确的HTML内容,但是第三次它只会显示一个空的body。
我需要网络应用程序能够在不影响浏览器窗口的情况下更新 iframe 内的页面,所以
target="_blank"
和 window.top.location=
都出来了。谷歌阻止postMessage()
所以我不能消息父窗口更新iframe src.
有没有办法从框架内更新 iframe 的 src 而不能使用
postMessage()
并且同时是跨源的?