Hi Beni, I've thrown together a pretty nifty plugin for handling this exact thing. (Neat problem to work on. :D )
Anyway, the plugin can be found here: http://snipplr.com/view/15393/inheritjs--jquery-sharing-between-parents-and-iframes/ There's a live proof-of-concept demo available here: http://eric.garside.name/inherit/ Some things to note: * The iFrames who wish to inherit jQuery from the parent need to call: parent.inherit( window ); * This function returns the iFrames jQuery object, as well as sets it up. This means you can also use this inheritance declaration to bind a document.ready function: parent.inhert( window )(function(){ alert( 'The iFrame DOM is ready!' ); * All the iFrame source code you're including on your page MUST (can't stress this enough) come from the same domain. Browsers are designed to prevent manipulation of the DOM of a page on a different domain through an iFrame. If the page which includes the iframes is on the same domain as the iframe source content themselves, things should work out nicely. * Once you call the parent.inherit( window ); function from the iFrame, and the iFrame dom is ready, you can proceed to use jQuery as if it were natively included. Let me know if you have trouble getting it to work, or have questions/ feature requests (such as the ability to track iFrame dom references by an arbitrary identifier, something I was going to implement, but then decided I didn't care enough to at the time. :P ) On May 28, 3:04 pm, beni <[email protected]> wrote: > Hi, > > I am developing a web application with full of independent widgets in > form of iframes. > I would like to avoid embeding jquery (and jQuery UI) in each iframe's > head to reduce number of requests and want to use the libs from the > parent window instead. In iframes' head I tried the following code: > > window.$ = window.content.$; > window.jQuery = window.content.jQuery; > > Well it works but naturally as the jquery object belongs to the parent > document I can manipulate only the DOM nodes of parent document from > the iframe and not the DOM nodes of the iframe itself! > I think if I could replace the "document" object of "window.$" with > iframe's "document" object it would work! > > 1) any idea how, any other sollutions? > 2) Is "=" copy by value or by reference? If I succeed to replace the > "document" object in "window.$", will it be also replaced in > "window.content.$"? > > Thank you!

