Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么可以';我不能从本地文件加载jQuery吗?_Jquery_Google Chrome - Fatal编程技术网

为什么可以';我不能从本地文件加载jQuery吗?

为什么可以';我不能从本地文件加载jQuery吗?,jquery,google-chrome,Jquery,Google Chrome,我在本地.html文件中有一行: <script src="http//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> :(出了什么问题?应该是: <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

我在本地.html文件中有一行:

<script src="http//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
:(出了什么问题?

应该是:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
                 ^

^
如前所述,您可以使用:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

这是一个错误的URL,在http://中缺少冒号(:)

这可能是因为使用了速记
src=“//ajax.googleapis.com…
。浏览器将使用正确的方案在
/
前面加上前缀--
http:
https:
,但是,由于您在本地访问它,因此它在前面加上了一个
文件:
方案,该方案期望资源位于您的本地驱动器上


对于本地开发人员,请使用带有指定方案的完全限定URL,或者使用本地Web服务器,以便您可以使用
http
https
方案访问文档。

…哦,我从他们的repo复制了链接…我认为这是正确的。不知道他们为什么省略了
http
。@Aerovistae:他们使用的是protocol相对URL。@Aerovistae-如果您退出协议,则它将适用于HTTP或HTTPS。@KarlAnderson,但不适用于文件://(在本地pc上打开html文档,不使用web服务器)你在
http://
中错过了
,不使用http,而是使用
//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
,这并不少见。请参阅本文:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>