Html gwt-从iframe页面访问
mainpage.htmlHtml gwt-从iframe页面访问,html,gwt,dom,iframe,Html,Gwt,Dom,Iframe,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
<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>
下面是一些GWT小部件,需要使用id=“123”访问div:
DOM.getElementById(“123”).getAttribute(“名称”)
可以在内部页面中访问主页上的div吗?您应该可以使用parent.getElementById(“123”)来实现这一点
请注意,innerpage和mainpage可能需要位于同一个域中,以防止将其标记为跨站点脚本。使用jsni可以执行以下操作:
仅供参考--您不必将gwt部署为iframe…这也是一个好的观点,如果可以的话,我将直接将gwt部署到页面中,因为它还消除了其他麻烦。