Hi, thanks a lot for these inputs. I will try the defer attribute.
regards, S. On 5 fév, 05:31, Litty Preeth <[email protected]> wrote: > And also checkout that the </SCRIPT> tag is broken into two: sScript = > sScript + "</SCRIPT" + ">"; > If you dont do that then also it wont work. > > On Thu, Feb 5, 2009 at 9:59 AM, Litty Preeth <[email protected]> wrote: > > RootPanel.get().add(this); > > HTML html = new HTML(); > > this.add(html); > > String sHTML="<input type=button onclick=" + "go2()" + " > > value='Click Me'><BR>"; > > String sScript="<SCRIPT DEFER>"; > > sScript = sScript + "function go2(){ alert('Hello from inserted > > script.') }"; > > sScript = sScript + "</SCRIPT" + ">"; > > html.setHTML(sHTML+sScript); > > > This code works is IE also. > > > As per > > msdnhttp://msdn.microsoft.com/en-us/library/ms533897(VS.85).aspx<http://msdn.microsoft.com/en-us/library/ms533897%28VS.85%29.aspx> > > *"When using innerHTML** **to insert script, you must include the DEFER > > attribute in the script element."* > > > - Litty > > > On Wed, Feb 4, 2009 at 10:33 PM, Adam T <[email protected]> wrote: > > >> For loading from a Url try the following (being aware of the security > >> issues): > > >> /** > >> * Adds the necessary DOM script element. > >> * > >> * @param uniqueId A unique id for the DOM element. > >> * @param url Location of "script". > >> */ > >> public native void addScript(String uniqueId, String url) /*-{ > >> var elem = document.createElement("script"); > >> elem.setAttribute("language", "JavaScript"); > >> elem.setAttribute("src", url); > >> elem.setAttribute("id", uniqueId); > >> document.getElementsByTagName("body")[0].appendChild(elem); > >> }-*/; > > >> if you have direct code, perhaps just add the code as a child to the > >> "elem" created, i.e. elem.text = "alert('Hello')"; and ignore the > >> setAttribute("src", url) line?? > > >> //Adam > > >> On 4 Feb, 11:11, sgaide <[email protected]> wrote: > >> > Hi, > > >> > I'm looking for a clear answer about the possibility to inject > >> > javascript into the DOM using HTML widget. > >> > I have found two threads about this, with no definitive answers: > > >> > <http://groups.google.com/group/Google-Web-Toolkit/browse_thread/ > >> > thread/49cbe6bda567c1a9/a60c36f305f21337?lnk=gst&q=javascript > >> > +HTML#a60c36f305f21337> > > >> > and > > >> > <http://groups.google.com/group/Google-Web-Toolkit/browse_thread/ > >> > thread/6fb61e587d7eab8d/44c22a52f86feb36?lnk=gst&q=javascript > >> > +HTML#44c22a52f86feb36> > > >> > My application needs to inject some javascript code at runtime (the > >> > code is provided at runtime and can not be inserted in the html page > >> > or loaded using a 'dynamic' script file). The only way I found to do > >> > that is to create an HTML widget. The results are highly dependant on > >> > the browser : > > >> > - with Firefox all works pretty well > >> > - with Safari and IE7 it doesn't work at all (javascript code is not > >> > executed). Using Safari development inspector I can see the javascript > >> > code in the DOM, but it's not interpreted by the browser. > > >> > So is it really possible to inject javascript using an HTML widget ? > >> > if yes, how ? if no, is there any other way to do it ? > > >> > Thanks a lot, > > >> > regards, > > >> > Sebastien. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
