tom.whitcomb at digitalfocus.com
Fri May 27 19:55:55 PDT 2005
really valuable to use an iframe for a separate namespace.
You may have already tried this approach, but...
existing reusable functions via a parent.function() call. In turn, the
parent can reference its child iframe functions and properties as well.
Below is kind of a hack, but it shows what I'm trying to explain.
The NSAlloc function takes "<script>....</script>" in a string, writes it
into NSAlloc references resuable functions in the parent and conversely
the parent can reference functions and properties in the child.
var i = document.createElement('iframe');
i.style.visibility = 'hidden';
var d = i.contentWindow?i.contentWindow.document:i.contentDocument;
d.open(); d.write(s); d.close();
var win = i.contentWindow?i.contentWindow:i.contentDocument.defaultView;
win.allocNS = i; // save the iframe reference
So, I can do stuff like:
var x = 1;
var child = NSAlloc("<script>var y=2; alert(parent.x);</script>");
I store the iframe's address in the returned window object because I later
free it with NSFree(win);
The part I really like is I don't have to deal with name clashes.
> I actually want the new code to execute in the same context. I have
> some common user interface related functions that the loaded
> results, I call a method to set my next and previous links in the
> result widget.
> On 5/27/05, Tom Whitcomb <tom.whitcomb at digitalfocus.com> wrote:
>> Definitely nice and very useful.
>> collide with existing names in the current context? I've always relied
>> 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
>> > 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
>> > just to detect the transport model and avoid calling the extra
>> > 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
>> > andinvoking
>> > 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
>> > 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
>> Dojo-interest mailing list
>> Dojo-interest at dojotoolkit.org
> Dojo-interest mailing list
> Dojo-interest at dojotoolkit.org
Digital Focus | Tom Whitcomb | CTO | 703 561 5884
More information about the Dojo-interest