我打算在网站上托管我的应用程序。该应用程序将显示在其中的 iframe 中。 我需要我的应用程序全屏显示,无论如何我可以更改那个 iframe 的大小,它将从我的应用程序中保存我的应用程序? 我的应用程序和托管它的网站不是同一个域。
$("iframe", window.parent.document).css("width", "1000px");
这不起作用,因为网站和应用程序不属于同一域
最佳答案
如果您的应用需要全屏运行,最明智的方法是脱离 iframe。也就是说,检测您的页面是否在 iframe 中,如果是,则将浏览器重定向到您的页面,这样它就不再在 iframe 中了!
This page解释如何去做:
<script type="text/javascript">
if (top.location!= self.location) {
top.location = self.location.href;
}
</script>
关于javascript - 是否可以从内部更改 iframe 的宽度/高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18248428/