简体   繁体   English

//和http://之间的区别

[英]Difference Between // and http://

I know that HTTP is hyper text transfer protocol, and I know that's how (along with HTTPS ) one accesses a website. 我知道HTTP是超文本传输​​协议,我知道如何(以及HTTPS )访问网站。 However, what does just a // do? 但是, //做什么呢? For instance, to access Google's copy of jQuery, one would use the url //ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js , as opposed to http://... . 例如,要访问Google的jQuery副本,可以使用url //ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js ,而不是http://...

What exactly is the difference? 究竟有什么区别? What does just // indicate? 只是//表示什么?

Thanks. 谢谢。

By saying on // it means use whatever protocol (IE: http vs https) your user is currently hittin for that resource. 通过说//这意味着使用任何协议(IE:http vs https),您的用户目前正在使用该资源。

So you don't have to worry about dealing with http: vs https: management yourself. 因此,您不必担心自己处理http:vs https:management。

Avoiding potential browser security warnings. 避免潜在的浏览器安全警告。 It would be good practice to stick with this approach. 坚持这种方法是一种好习惯。

For example: If your user is accessing http://yourdomain/ that script file would automatically be treated as http://ajax.googleapis.com/... 例如:如果您的用户正在访问http://yourdomain/该脚本文件将自动被视为http://ajax.googleapis.com/...

if your current request is http 如果您当前的请求是http

//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js 

will be treated as 将被视为

http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js

if your current request is https 如果您当前的请求是https

//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js 

will be treated as 将被视为

 https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM