scripts[i].getAttribute("src") is going to be something like
'myscript.js'

you can't just eval that string. Are you trying to fetch the js and
eval? I'd imagine you need to do that explicitly.

-Jeff

On Feb 12, 2:23 pm, Matt Raible <[email protected]> wrote:
> I'm trying to integrate analytics into my GWT application. To do this,
> I'm calling a service that returns a String of HTML that needs to be
> parsed and eval'ed. The following seems to work to eval() the contents
> of a <script> tag, but it fails (silently) if I try to parse a .js
> file (referenced in a "src" attribute). Any ideas why?
>
> Thanks,
>
> Matt
>
>             try {
>                 evalJS(new HTML(response).getElement());
>             } catch (JavaScriptException jse) {
>                 GWT.log("Failed to parse analytics scripts.", jse);
>                 GWT.log("Analytics script contents: " + response,
> null);
>             }
>
>     public static native String evalJS(Element e) /*-{
>         var scripts = e.getElementsByTagName("script");
>
>         for (i=0; i < scripts.length; i++) {
>             // if src, eval it, otherwise eval the body
>             if (scripts[i].hasAttribute("src")) {
>                 eval(scripts[i].getAttribute("src")); // silently
> fails here
>             } else {
>                 eval(scripts[i].innerHTML); // this works
>             }
>         }
>     }-*/;
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to