Why would you need prototype? just use RequestBuilder to fetch the text, and pass the result into your JSNI eval() ...
-jason On Feb 12, 2009, at 4:17 PM, jdwyah wrote: > > js only I guess you could do an Ajax.Request, but in JSNI you don't > have Prototype.. > > I dunno, I feel like you're descending down the rabbit hole. I wonder > if there's another approach. > > -jdwyah > > On Feb 12, 3:56 pm, Matt Raible <[email protected]> wrote: >> How do I go about fetching the script and then eval'ing it? >> >> Thanks, >> >> Matt >> >> On Feb 12, 11:45 am, jdwyah <[email protected]> wrote: >> >>> 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 -~----------~----~----~----~------~----~------~--~---
