0

我有一个包含 GWT 代码的 iframe。我想从该代码中动态更改 iframe 尺寸。

我正在尝试以下操作:

Element iframe = we start from some element inside the iframe;
while (!iframe.getTagName().toLowerCase().equals("iframe")) { // get embedding iframe
    iframe = iframe.getParentElement();
}

iframe.setAttribute("style", "height:100px;width:100px;");

它不起作用。在中间的某个地方,我在到达 iframe 之前到达了一个 null 父级。

如何从在 iframe 本身中运行的 GWT 更改 iframe 尺寸?我不介意它是否是基于 JSNI 的解决方案。

谢谢!

4

1 回答 1

1

你不能这样做。如果 iFrame 内的文档在您的域中,而包含 iFrame 的文档在不同的域中,则安全机制将阻止您从一个到另一个进行任何更改。

于 2012-11-21T17:46:59.870 回答