您是否可以拥有脚本的备用源? [英] Are you allowed to have an alternate source for a script?
本文介绍了您是否可以拥有脚本的备用源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在HTML5中使用javascript的替代来源?例如,我正在使用jQuery,并在本地使用它。但我允许包含一个 alt
属性,这样如果不起作用,Google的jQuery会加载吗?
Is is possible to have an alternate source for a javascript in HTML5? For example, I am using jQuery, and have it locally. But an I allowed to include an alt
attribute so that if that doesn't work, Google's jQuery will load?
如果有效,代码看起来像这样:< script src =在此处输入你的文字.jsalt =googlescode>< / script>
If it works, the code would look something like this: <script src="enter your text here.js" alt="googlescode"></script>
推荐答案
如果是jQuery,你可能想看看这篇文章。
If it is jQuery, you might want to look at this article.
Snippet:
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-2.0.0.min.js"></script>
<script>
if (typeof jQuery == 'undefined') {
document.write(unescape("%3Cscript src='/js/jquery-2.0.0.min.js' type='text/javascript'%3E%3C/script%3E"));
}
</script>
这篇关于您是否可以拥有脚本的备用源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文