【问题标题】:gwt - access from iframe pagegwt - 从 iframe 页面访问
【发布时间】:2011-06-29 19:08:44
【问题描述】:

mainpage.html

<html>
<div id="123" name="foo"></div>
<iframe src="/innerpage.html"></iframe>
</html>

innerpage.html:

<html> 
 and here is some GWT widget that needs to access the div with id="123":
 DOM.getElementById("123").getAttribute("name") 
</html>

是否可以在内页中访问主页上的div?

【问题讨论】:

  • 仅供参考——您不必将 gwt 部署为 iframe...
  • 这也是一个好点,如果可以的话,我会将 GWT 直接部署到页面中,因为它也消除了其他令人头疼的问题。

标签: html gwt dom iframe


【解决方案1】:

使用 jsni 你可以这样做:

iframe accessing parent DOM?

【讨论】:

    【解决方案2】:

    您应该可以使用 parent.getElementById("123"); 来做到这一点

    请注意,内页和主页可能需要位于同一域中,以防止这被标记为跨站点脚本。

    【讨论】:

      猜你喜欢
      • 2011-07-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-24
      • 1970-01-01
      • 2014-05-20
      • 2012-05-31
      • 2011-08-09
      相关资源
      最近更新 更多