I want to include Javascript code in a HTMLPanel element, but it is not working. Could you please help me? Thanks in advance.
Scripts/pro.js
alert('hello');
WITH HTMLPANEL DOES NOT WORK (no alert is displayed)
MyPage.java (which is EntryPoint for MyPage.html)
String preHtml="<script type=\"text/javascript\" src=\"Scripts/pro.js\"></script>";
HTMLPanel prePanel=new HTMLPanel(preHtml);
RootPanel.get("scriptContainer").add(prePanel);
MyPage.html
<td align="left" valign="top" id="scriptContainer"></td>
WITHOUT HTMLPANEL DOES WORK (alert is displayed)
MyPage.html
<td align="left" valign="top"><script type="text/javascript" src="Scripts/pro.js"></script></td>
I think it should be other way around. The HTMLPanel quoting the javadocs
should wrap your container not your script. The below example works unless you absolutely have a reason to use HTMLPanel to wrap a script.