jquery js import to iframe
I have a page that uses jquery ui's tabs. Each tab content is开发者_开发知识库 an iframe with a local page in it. These local pages have been importing their own jquery.js when their parent also have jquery.js imported.
Is there any way i can use the parents jquery inside the iframes, so I dont have to add jquery.js to every single page inside the iframe?
I know parent.$ may work, but I dont want to call parent on every function. Can i instantiate the jquery object from the parent?
Put this on the Iframe and you are done...
var $ = function() {
var args = [arguments[0], document];
return parent.$.apply(null, args);
};
Try var $ = parent.$
, or something along those lines, at the beginning of your javascript.
精彩评论