Well for example the changes I've made allow you to get the width/height of
a different document/window by passing them into jQuery...
$('iframe').contents().width() // should return the width of the iframe
document

Another example is the css method that use to be restricted to its loaded
window to return computed styles in Firefox.

--
Brandon Aaron

On Wed, Apr 22, 2009 at 4:49 PM, Julian Aubourg <[email protected]>wrote:

> Sounds awesome but will it feature a way to change the internal window and
> document references globally for an instance of jQuery? Or is it an
> additional parameter? (just how of curiosity)
>
> 2009/4/22 Brandon Aaron <[email protected]>
>
> Just an FYI... yesterday I checked in some patches that enable several
>> window/document dependent methods to work with other windows/documents than
>> the one jQuery is loaded in. I believe there are still some patches to be
>> made but overall jQuery 1.3.3 should operate better under situations like
>> this.
>> --
>> Brandon Aaron
>>
>>
>> On Wed, Apr 22, 2009 at 4:41 PM, Julian Aubourg <[email protected]
>> > wrote:
>>
>>> Yep, the someone was me. And as Daniel points out, the problem with
>>> sandboxing is that it is permeable but not transparent.
>>> You could go around onstart manipulations by hacking the script (i.e.
>>> point to window.top rather than window) but you'd also have to hack into all
>>> of the script's functionalities (as soon as it involves document
>>> manipulation without any given context -- i.e. a parameter that is the group
>>> of nodes to act on). And, beside, you'd need to hack jQuery itself too.
>>>
>>> But from an engine point of view, I think what could be interesting would
>>> be to have a way to make jQuery sandboxed in an iframe and have its internal
>>> window reference being redirected. Something like a
>>> jQuery.setContextWindow() function. But I'm pretty confident this would mean
>>> quite some refactoring within jQuery itself, wouldn't it? Unless redefining
>>> the window variable within the jQuery main function closure would be enough?
>>>
>>> Anyway, this would make it possible to have an iframe content like this:
>>>
>>> <script src="JQUERY_URL" />
>>> <script>jQuery.setContextWindow(window.top);</script>
>>> <script src="OTHER_SCRIPT_URL" />
>>>
>>> The icing on the cake would be to have access to this context window with
>>> something like jQuery.getContextWindow() so that plugins could use it and be
>>> as transparently sandboxed as jQuery itself.
>>>
>>> 2009/4/22 Daniel Friesen <[email protected]>
>>>
>>>
>>>> There was someone who did some work on a jQuery JSONP plugin which did
>>>> more than the simple stuff jQuery does, including onerror callbacks. It
>>>> was done using an iframe trick as well.
>>>>
>>>> An iframe is a bit of a possibility.
>>>>
>>>> if( window.jQuery !=== jQuery)
>>>> var iframe = create iframe
>>>> iframe.contentWindow.jQuery = jQuery;
>>>> create script tag and insert
>>>> jQuery(iframe).remove();
>>>>
>>>>
>>>> However the issue with the iframe sandbox is that the document and
>>>> whatnot isn't properly available.
>>>>
>>>> ~Daniel Friesen (Dantman, Nadir-Seen-Fire)
>>>>
>>>> Andrea Giammarchi wrote:
>>>> > I feel "called in the cause" ... globalEval just evaulate code, if it
>>>> > causes problems, you need a sandbox to run multiple version of jQuery
>>>> > or whatever library (a sandbox for each library) and a manager to
>>>> > delegate tasks to the right sandbox when you need it.
>>>> >
>>>> > What's a sandbox? ... poorly speaking, an iframe and its window object
>>>> > with its global variables (libraries included)
>>>> >
>>>> > Hope this help.
>>>> >
>>>> > Best Regards
>>>> >
>>>> > On Wed, Apr 22, 2009 at 6:22 PM, John Resig <[email protected]
>>>> > <mailto:[email protected]>> wrote:
>>>> >
>>>> >
>>>> >     Hmm... I do understand your predicament (wanting the
>>>> >     dynamically-loaded script to use the right version of jQuery). I'm
>>>> >     trying to imagine situations where your change could cause
>>>> potential
>>>> >     problems, but I'm not sure, yet.
>>>> >
>>>> >     FWIW, this problem also affects getScript when pulling scripts
>>>> from an
>>>> >     outside domain (and it can't be fixed used the technique described
>>>> >     here since there's no window of opportunity where the global
>>>> jQuery
>>>> >     variable could be changed).
>>>> >
>>>> >     I also note that you only change 'jQuery' and not '$' - it seems
>>>> like
>>>> >     both would be necessary, in this case.
>>>> >
>>>> >     But, again, I'm worried about the external affects of manipulating
>>>> the
>>>> >     global variables.
>>>> >
>>>> >     --John
>>>> >
>>>> >
>>>> >
>>>> >     On Wed, Apr 22, 2009 at 1:04 PM, Mark Gibson <[email protected]
>>>> >     <mailto:[email protected]>> wrote:
>>>> >     >
>>>> >     > Hi, I'm using jQuery in a high conflict situation, ie. multiple
>>>> >     > versions of jQuery in one page.
>>>> >     > Unfortunately I have no way around this other than not using the
>>>> >     latest jQuery.
>>>> >     >
>>>> >     > So first off, jQuery 1.2 is loaded and noConflict() called.
>>>> >     > Later, jQuery 1.3.2 is loaded and fed into a closure as such:
>>>> >     >
>>>> >     > (function($) {
>>>> >     > ...
>>>> >     > })( jQuery.noConflict(true) );
>>>> >     >
>>>> >     > Within the closure if I try to dynamically load some html that
>>>> >     > contains script then the script will be executed with jQuery 1.2
>>>> as
>>>> >     > the global jQuery object.
>>>> >     > I believe it would be more appropriate to temporarily set the
>>>> global
>>>> >     > jQuery to the one loading the script, ie. 1.3.2 in this case.
>>>> >     >
>>>> >     > I've got two demo's, first without the patch, second with the
>>>> patch:
>>>> >     >
>>>> >     >
>>>> >     http://test3.internal.adaptavist.net/~mgibson/versions/load1.html
>>>> >     <
>>>> http://test3.internal.adaptavist.net/%7Emgibson/versions/load1.html>
>>>> >     >
>>>> >     http://test3.internal.adaptavist.net/~mgibson/versions/load2.html
>>>> >     <
>>>> http://test3.internal.adaptavist.net/%7Emgibson/versions/load2.html>
>>>> >     >
>>>> >     > It this worth considering, shall I raise a ticket?
>>>> >     >
>>>> >     >
>>>> >     > Here's the patch:
>>>> >     >
>>>> >     > Index: src/core.js
>>>> >     >
>>>> ===================================================================
>>>> >     > --- src/core.js (revision 6319)
>>>> >     > +++ src/core.js (working copy)
>>>> >     > @@ -290,7 +290,10 @@
>>>> >     >                        // Inspired by code by Andrea Giammarchi
>>>> >     >                        //
>>>> >
>>>> http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
>>>> >     >                        var head =
>>>> >     document.getElementsByTagName("head")[0] ||
>>>> >     > document.documentElement,
>>>> >     > -                               script =
>>>> >     document.createElement("script");
>>>> >     > +                               script =
>>>> >     document.createElement("script"),
>>>> >     > +                               globaljQuery = window.jQuery;
>>>> >     > +
>>>> >     > +                       window.jQuery = jQuery;
>>>> >     >
>>>> >     >                        script.type = "text/javascript";
>>>> >     >                        if ( jQuery.support.scriptEval ) {
>>>> >     > @@ -303,6 +306,8 @@
>>>> >     >                        // This arises when a base node is used
>>>> >     (#2709).
>>>> >     >                        head.insertBefore( script,
>>>> head.firstChild );
>>>> >     >                        head.removeChild( script );
>>>> >     > +
>>>> >     > +                       window.jQuery = globaljQuery;
>>>> >     >                }
>>>> >     >        },
>>>> >     >
>>>> >     > >
>>>> >     >
>>>> >
>>>> >
>>>> >
>>>> >
>>>> > >
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" 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/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to