是否有可能加载和使用jquery在父iframe页面和内部iframe没有加载jquery两次,这意味着在页面中加载jquery一次,并在内部的ifrmae中使用它。
is it possible to load and use jquery in the parent iframe page & inside the iframe whithout loading jquery twice, meaning to load jquery just once in the page and using it in the ifrmae within.
最满意答案
当然,只要确保<iframe>不加载jQuery脚本,即<script src="....">那么您可以在父级访问jQuery实例,如下所示:
var $ = window.top.$;确保使用第二个参数使用正确的上下文:
$('img', document);如果这是不可能的,你不能“阻止”脚本被下载和执行。
Sure, just make sure the <iframe> isn't loading the jQuery script i.e. <script src="...."> then you can access the jQuery instance in the parent like so:
var $ = window.top.$;Be sure to use the correct context using the second parameter:
$('img', document);If this isn't possible you can't "prevent" a script from being downloaded and executed.
更多推荐
jquery,iframe,使用,load,电脑培训,计算机培训,IT培训"/> <meta name="descrip
发布评论