为什么使用<link href="//something.com/style.css" rel="stylesheet">
而不是在域名前加上http://
或https://
?
如果我们使用href=//
,链接会发生变化吗?例如,在SSL模式下,它会自动更改为https://
吗?
为什么使用<link href="//something.com/style.css" rel="stylesheet">
而不是在域名前加上http://
或https://
?
如果我们使用href=//
,链接会发生变化吗?例如,在SSL模式下,它会自动更改为https://
吗?
是的,它将使用当前协议。
即,如果当前页面为 https
,则它将使用 https
访问 href
。
如果是 http
,那么链接将通过纯粹的 http
访问。
这将防止浏览器警告,如果托管页面是 https
,并且比普通的 http
链接更安全。