Javascript is not executed in ScriptElement

I’ve written my own widget with two ScriptElements in the paintContent.
But the javascript is only executed in IE not in FF.

If I execute javascript manually in the console afer the page is loaded , it works also in FF
Any suggestions ? Thanks !!

One for import:


ScriptElement fcs = Document.get().createScriptElement();
fcs.setType("text/javascript");
fcs.setSrc("path/to/myScrip.js");
getElement().appendChild(fcs);

One for execution:


ScriptElement scriptElement = Document.get().createScriptElement();
scriptElement.setType("text/javascript");
scriptElement.setText("myScript.execute()");
getElement().appendChild(scriptElement);

Are you sure, that the Javascript doesn’t get executed at all? Have you tried putting a simply window.alert() somewhere at the beginning of your code (or used a debugger)? Maybe you are just using some construct that doesn’t work in FF and your script gets halted with an unnoticed error.

Thank you for your reply.
You are right. Perhaps something is wrong with the code.

The “window.alert()” works in FF and it’s a positiv proof that FF handles the element.
The inspected code within in the script element works if it’s executed in the console.

I’ll will check my code and make it simpler for debugging it step by step…

Thanks…

Executing the JS-code in the console afterwards is no good mean to find possible bugs. The DOM for example will be available only partly when the JS gets run the first time, so getElementById() will return null for all Elements coming after your script-tag. Also Vaadin / GWT might not have finished it’s work completely at that point.

What I am saying is: The environment in which your JS is running while the page is loading is totally different from the environment it is running in when you execute it from the JS-console.

I added them in a static way to the custom widgetset xml. Now it works.
It seems that javascripts loading in IE works different to FF.