问题描述
以下是GWT 生成的代码,这段代码直接在 html.body插入iframe, 我如何控制在我指定的 div 中插入iframe呢?我不能直接修改生成的js吧, 如何在java中控制呢?function arden_gwt_Main(){ var $wnd_0 = window, $doc_0 = document, ...}function maybeInjectFrame(){ if (!frameInjected) { frameInjected = true; var iframe = $doc_0.createElement('iframe'); ... iframe.tabIndex = -1; $doc_0.body.appendChild(iframe); ... } }问题补充自己发现答案了:RootPanel rootPanel = RootPanel.get("contentwrapper");
解决方案
<html><head><title>Wrapper HTML for Dashboard</title></head><body><script language="javascript" src="gwt.js"></script><iframe id="__gwt_historyFrame"style="width:0;height:0;border:0"></iframe><h1>Dashboard</h1><p>This is an example of a host page for the Dashboardapplication. You can attach a Web Toolkit module toany HTML page you like, making it easy to add bitsof AJAX functionality to existing pageswithout starting from scratch.</p><table align=center><tr><td id="slot1"></td><td id="slot2"></td></tr></table></body></html>RootPanel.get("slot1").add(button);RootPanel.get("slot2").add(label);这种方法也可以。但是大部分情况是创建不同的Panel,并添加到body中去:FlowPanel panel = new FlowPanel();Button btn = new Button("dddd",false);panel.add(btn);RootPanel.get().add(panel);