[Dojo-interest] Invoking Javascript [was: Fetching HTMLandinvoking javascript with io.bind]

Tom Whitcomb tom.whitcomb at digitalfocus.com
Fri May 27 17:28:42 PDT 2005

Definitely nice and very useful.

Wouldn't you be concerned that the fetched/executed javascript could
collide with existing names in the current context?  I've always relied
upon an iframe to isolate any fetched javascript so I could be sure no
collisions occured.  Why do you prefer this approach over an iframe


> Cool stuff. Couple of comments:
> Why not stuff the content into the container, then node-walk to find the
> scripts instead of extracting them with RegEx? That would avoid the
> debug-the-regex step.
> Wrt IFRAME transport, maybe one could use a custom tag for embedded
> scripts
> (dscript or something) to avoid auto-executing those bits. Probably easier
> just to detect the transport model and avoid calling the extra execution
> step.
> Scott
> -----Original Message-----
> From: dojo-interest-bounces at dojotoolkit.org
> [mailto:dojo-interest-bounces at dojotoolkit.org] On Behalf Of Josh Reed
> Sent: Friday, May 27, 2005 10:29 AM
> To: Dojo-interest at dojotoolkit.org
> Subject: [Dojo-interest] Invoking Javascript [was: Fetching HTML
> andinvoking
> javascript with io.bind]
> Hello all,
> Sorry for jumping out the previous thread, but I just joined the
> mailing list.  I was browsing the archives and saw the thread.
> I'm using io.bind in an interface that I'm building and I addressed
> this issue of pulling back HTML and invoking javascript embedded in
> it.  I went ahead and coded up a javascript method to do it.  Check
> out: http://cws3.geol.iastate.edu:8080/xqe/scripts/dhtml.js
> The function in question is called executeScripts(). Basically it
> looks through the returned content and requests external scripts (e.g.
> they have a src="" attribute).  If the script is inline, it evals().
> Currently, I think it only works for inlined scripts on a single line
> e.g.
> <script>alert('hi')</script>
> but not
> <script>
>   alert('hi!');
> </script>
> I don't know how well this approach will work with other
> transports...it seems like an iframe wouldn't need to worry about it
> because the scripts should get executed as part of the loading.  Dunno
> though.
> I think it is just a matter of some debugging on my part.  Anyhow,
> seems to work well across browsers.  I use the technique fairly
> extensively in the interface at:
> http://cws3.geol.iastate.edu:8080/xqe/
> Thanks,
> Josh Reed
> --
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.322 / Virus Database: 267.1.0 - Release Date: 5/27/2005
> _______________________________________________
> Dojo-interest mailing list
> Dojo-interest at dojotoolkit.org
> http://dojotoolkit.org/mailman/listinfo/dojo-interest

Digital Focus  |  Tom Whitcomb  |  CTO  | 703 561 5884

More information about the Dojo-interest mailing list