Double slash at beginning of javascript include

此生再无相见时 提交于 2019-12-04 03:17:54

问题


I have been looking at the html5 boilerplate and noticed that the jquery include url starts with a double slash. The url is //ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js

Why is the http: missing?


回答1:


I hate answering with a link but this explains it - http://paulirish.com/2010/the-protocol-relative-url/


Using a protocol relative URL like "//mydomain/myresource" will ensure that the content will be served via the same scheme as the hosting page. It can make testing a bit more awkward if you ever use FILE:// and then some remote locations as they will obviously resolve back to FILE. Never the less it does resolve the mixed insecure/secure content messages you can cause by not using it.




回答2:


So that if the .html is accessed via HTTPS; the page will not have any unsecured script.



来源:https://stackoverflow.com/questions/6350244/double-slash-at-beginning-of-javascript-include

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!