他们是否可以将javascript嵌入GWT代码中?

时间:2016-10-30 19:32:23

标签: javascript html gwt

最终HTML statushHTML =新HTML(“”,true);

statushHTML.setHTML(结果);

//结果我传递字符串


1. result = <b> bold </b>   // it displays bold
2. result = <i> italics </i> // it works
3. result = <font color='red'> red </font>  // it works again
4. result = <h1> h1 tag </h1> // this also works fine

But if i try

5. result = <script> alert('No output') </script> // now it doesn't work


It's just displaying it in string format.

1 个答案:

答案 0 :(得分:0)

如果您需要使用ScriptInjector插入脚本。

示例代码:

String script = "alert('No output')";
ScriptInjector.fromString(script).inject();