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 -~----------~----~----~----~------~----~------~--~---
