2012-11-20 43 views
0

我有一個包含GWT代碼的iframe。我希望從該代碼動態更改iframe維度。GWT從內部以編程方式設置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之前到達了一個空父母。

如何從iframe中運行的GWT更改iframe維度?我不介意它是否是基於JSNI的解決方案。

謝謝!

回答

1

你不能這樣做。如果iFrame中的文檔位於您的域中,並且包含iFrame的文檔位於不同的域中,那麼安全機制將阻止您對其中一個進行任何更改。