我试过这个:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" type="text/javascript"></script>
<script src="//ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.unobtrusive-ajax.min.js" type="text/javascript"></script>
<script src="//ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.validate.unobtrusive.min.js type="text/javascript"></script>
<link href="@Url.Content("~/Content/Stylesheets/selectbox.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery.selectbox-0.5.js")" type="text/javascript"></script>
<script type="text/javascript">
window.jQuery || document.write('<script src="/Scripts/jquery/jquery-1.6.1.min.js">\x3C/script>')
window.jQuery || document.write('<script src="/Scripts/jquery/jquery.unobtrusive-ajax.min.js">\x3C/script>')
window.jQuery || document.write('<script src="/Scripts/jquery/validate.validate.min.jss">\x3C/script>')
如果我没有连接到互联网并在本地运行,那么它就会挂起。是否有一个很好的推荐方法来加载外部javascrpt,如来自谷歌的那些。也许我可以在我的视图中编写一些代码来检查互联网是否可用,如果没有,它会加载本地脚本?
答案 0 :(得分:0)
检测jquery插件的另一个选项是可用/已加载或不加载::
if(typeof jQuery.fn.**PLUGIN_FUNCITON_NAME** == 'function'){
//jQuery plugin calling goes here
}
但必须在jQuery本身成功加载后调用它... 要检查jQuert,试试这个:
if (typeof jQuery == 'undefined'){
//jQuery scripting goes here
}