0
我想将谷歌小工具添加到FlowPanel(或HTMLPanel)中,但是在加载主机页之后,它会从我的页面导航并在新页面中显示小工具,如果我单击浏览器的后退按钮会加载主机页面,并再次导航到新页面以显示小工具。无法将外部脚本添加到gwt小部件
下面是代码:
String code="here_goes_scrip_tag_for_gadget";
flowPanel.add(new HTML(SafeHtmlUtils.fromTrustedString(code)));
什么我做错了,请帮助。
UPDATE 上面的代码加载脚本是错误的,我已经修改了它如下:
FlowPanel gadgetContainer = new FlowPanel();
Element script = Document.get().createScriptElement();
script.setAttribute("type", "text/javascript");
script.setAttribute("src", "http://www.gmodules.com/ig/ifr?url=http://digg.com/goog/ig.xml&up_user=&up_thumbnail=1&up_filter=0&up_num=5&up_type=popular&up_refresh=0&up_tab=0&up_offset=0&up_pagination=0&up_business=true&up_entertainment=true&up_gaming=true&up_lifestyle=true&up_offbeat=true&up_politics=true&up_science=true&up_sports=true&up_technology=true&up_world_news=true&synd=open&w=320&h=200&title=Digg&border=%23ffffff%7C3px%2C1px+solid+%23999999&output=js");
gadgetContainer.getElement().appendChild(script);
但它仍然无法正常工作。
感谢提到ScriptInjector,我会看看。小工具代码非常简单,它来自www.google.com/ig/directory?synd=open&cat=news上的公共存储库,我试图将其加载到纯html页面中,并且按预期工作,无重定向,脚本创建一个iframe并将小工具加载到其中。 – Zhaidarbek