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