Google CDN的jQuery UI的后备 [英] Fallback for jQuery UI from google CDN
本文介绍了Google CDN的jQuery UI的后备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果从Google CDN抓取失败,Html5 Boilerplate使用以下技巧来回退到本地存储的JQuery:
<script>!window.jQuery && document.write(unescape('%3Cscript src="js/libs/jquery-1.4.2.js"%3E%3C/script%3E'))</script>
您将如何实施此技巧以对jQuery UI执行相同的技巧?
解决方案
<script type="text/javascript">!window.jQuery.ui && document.write(unescape('%3Cscript src="path to jquery UI lib'))</script>
在对jQuery本身进行后备操作后执行此操作.
或者(如果您不喜欢!)
<script type="text/javascript">(window.jQuery.ui === /* notice the === */ undefined) && document.write( /* ... */)</script>
Html5 Boilerplate uses the following trick for fallback to locally stored JQuery if grabbing it from Google CDN fails:
<script>!window.jQuery && document.write(unescape('%3Cscript src="js/libs/jquery-1.4.2.js"%3E%3C/script%3E'))</script>
How would you implement this trick to perform the same trick for jQuery UI?
解决方案
<script type="text/javascript">!window.jQuery.ui && document.write(unescape('%3Cscript src="path to jquery UI lib'))</script>
Do this after the fallback for jQuery itself.
Or (if you don't like the !)
<script type="text/javascript">(window.jQuery.ui === /* notice the === */ undefined) && document.write( /* ... */)</script>
Detecting an undefined object property
这篇关于Google CDN的jQuery UI的后备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文