最近公司有個項目在我本地運行時引用本地的jquery.js,瀏覽器提示無法加載
<script src="/js/newperson/jquery-1.11.3.min.js" type="text/javascript"></script>
但引用網絡JS則可以正常使用
<script src="http://www.wodexiangce.cn/js/jquery-1.11.3.min.js" type="text/javascript"></script>
網上找了找這種問題的解決方法,沒找到具體的原因,由於時間限制,沒有繼續深入了解,直接使用了網絡JS。
這里記錄下引用網絡JS的幾種方式:
1、直接使用外部庫
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
2、局域網引用JS庫
<script type="text/javascript" src="${pageContext.request.contextPath}/script/easyUI/jquery-1.4.4.min.js"></script>
3、jQuery庫外部引用無法加載時自動加載本地jQuery庫
Google jQuery庫加載代碼:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript">window.jQuery || document.write('<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/jquery.min.js">\x3C/script>')</script>
Microsoft jQuery庫加載代碼:
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.2.min.js"></script> <script type="text/javascript">window.jQuery || document.write('<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/jquery.min.js">\x3C/script>')</script>
SAE jQuery庫加載代碼:(國內新浪Sae提供的jQuery庫)
<script type="text/javascript" src="http://lib.sinaapp.com/js/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript">window.jQuery || document.write('<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/jquery.min.js">\x3C/script>')</script>
