On Mon, Jul 27, 2009 at 9:04 PM, John Resig<jere...@gmail.com> wrote: > Yeah, I'm with Andrea here - that seems much safer (and more generic). Gael > - can you verify that this change works for you? > > --John > > > On Mon, Jul 27, 2009 at 2:23 PM, Andrea Giammarchi > <andrea.giammar...@gmail.com> wrote: >> >> var head = doc.getElementsByTagName("head")[0] || doc.documentElement; >>
This doesn't work. It seems that in this case the script can't access the window[jsonp] function. But everything work if I use the XUL document to create the script element (see patch below). Strange behavior... 3476,3477c3476,3477 < var head = document.getElementsByTagName("head")[0]; < var script = document.createElement("script"); --- > var head = document.getElementsByTagName("head")[0] || > document.documentElement; > var script = > window.content.document.createElement("script"); >> ??? >> >> On Thu, Jul 23, 2009 at 11:42 PM, Gaël Pasgrimaud >> <gael.pasgrim...@gmail.com> wrote: >>> >>> Hi, >>> >>> I'm using jQuery in a Firefox extension to modify the current >>> document. It work great. >>> I only have problems with ajax request. >>> >>> When you use getJSON in a FF extension the document object has no >>> <head /> but jQuery try to use it to add a <script /> tag. >>> The problem is located in the $.ajax() function. >>> >>> The patch bellow fix the problem: >>> >>> % diff jquery-1.3.2.js apwalfr/content/jquery.js >>> 3433c3433,3434 >>> < window[ jsonp ] = function(tmp){ >>> --- >>> > var w = window.content.document.wrappedJSObject ? >>> > window.content.window.wrappedJSObject : window; >>> > w[ jsonp ] = function(tmp){ >>> 3438,3439c3439,3440 >>> < window[ jsonp ] = undefined; >>> < try{ delete window[ jsonp ]; } catch(e) >>> {} >>> --- >>> > w[ jsonp ] = undefined; >>> > try{ delete w[ jsonp ]; } catch(e){} >>> 3476,3477c3477,3479 >>> < var head = document.getElementsByTagName >>> ("head")[0]; >>> < var script = document.createElement("script"); >>> --- >>> > var doc = window.content.document.wrappedJSObject >>> > ? window.content.document : document; >>> > var head = doc.getElementsByTagName("head")[0]; >>> > var script = doc.createElement("script"); >>> >>> This way jQuery use the current window / document to add the <script >>> /> tag and everything work fine. >>> >>> Don't know if this is 100% OK for all browsers but AFAIK >>> window.content.document.wrappedJSObject is only defined when you are >>> in a FF extension. >>> >>> Hope someone can improve and apply this patch. >>> >>> Regards, >>> >>> Gael >>> >>> >> >> >> > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~----------~----~----~----~------~----~------~--~---