最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Simulate an "include_once" for jQuery - Stack Overflow

programmeradmin0浏览0评论

I have created a simple page that use jQuery, so include jquery.min.js.

But I have to insert an iFrame in the same page (and no, unfortunately I can't use anything else) that include a different versione of jquery.min.js.

How can I force the browser to include only one of those two version (like an include_once in php)?

Thank you!

I have created a simple page that use jQuery, so include jquery.min.js.

But I have to insert an iFrame in the same page (and no, unfortunately I can't use anything else) that include a different versione of jquery.min.js.

How can I force the browser to include only one of those two version (like an include_once in php)?

Thank you!

Share Improve this question asked Oct 25, 2011 at 10:13 Marco PaceMarco Pace 3,87021 silver badges38 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 10

Not tested but at the end of your page, just before </body> tag, you can add this:

<script>
  window.jQuery || document.write('<script src="js/jquery.min.js"><\/script>')
</script>

This checks if jQuery is available or not, if not it will add one dynamically from path specified.

发布评论

评论列表(0)

  1. 暂无评论