JavaScriptException -> Trying to add script element to body in onModuleLoad()

169 views
Skip to first unread message

maku

unread,
Aug 29, 2008, 7:16:32 AM8/29/08
to Google Web Toolkit
When I try to add a script element to the document body I get an Error
when I set the Element instance -> setInnerHTML. (GWT 1.5)

public void onModuleLoad() {

Element script = DOM.createElement("script");
script.setInnerHTML("..."));
RootPanel.getBodyElement().appendChild(script);

}


[ERROR] Unable to load module entry point class
com.tfact.gwt.test.beanmodel.client.GxtBeanModelTest (see associated
exception for details)
com.google.gwt.core.client.JavaScriptException: (Error): Unbekannter
Laufzeitfehler
number: -2146827688
description: Unbekannter Laufzeitfehler
at com.google.gwt.dom.client.Element$.setInnerHTML$(Native Method)
at
com.tfact.gwt.test.beanmodel.client.GxtBeanModelTest.onModuleLoad(GxtBeanModelTest.java:
16)


Could anybody give me a hint whats going on?

TIA
Martin

Rene

unread,
Sep 6, 2008, 2:11:00 PM9/6/08
to Google Web Toolkit
I am having the same issue in ie

Folke

unread,
Sep 6, 2008, 2:39:47 PM9/6/08
to Google Web Toolkit
>         Element script = DOM.createElement("script");
>         script.setInnerHTML("..."));
>         RootPanel.getBodyElement().appendChild(script);

Set the "type" attribute first and then try to add your script with
setInnerText() or create a text node and append it as child.
Reply all
Reply to author
Forward
0 new messages