javascript - Load jQuery only once on many-framed page -
a key screen in application involves html page several iframe
s performing various functions. of these need access jquery. in interest of speeding loading time, , reducing http traffic (though know caching this), if jquery code loaded once. if page so
<html> <head> <script src="jquery-1.5.js" type="text/javascript"></script> </head> <body> <iframe src="other.html"></iframe> <div id="foo"> ... stuff here ... </div> </body> </html>
then inside other
can refer parent.$('#foo')
refer parent's "foo" element, not child's. there way use parent's "instance" of jquery on child document or elements in it?
have tried:
var $ = window.parent.$; $('#foo'); // parent's frame's #foo, same "window.parent.$('#foo');"
and:
var $ = window.parent.$; $('#foo', document); // frame's #foo because current document given context
Comments
Post a Comment