为什么我们使用双斜杠而不是http [英] why we use double slash instead http

查看:330
本文介绍了为什么我们使用双斜杠而不是http的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到一些将javascript文件链接到页面的网页,如下所示:

I see some web pages that link javascript file to page like this :

<script async="" src="//www.googletagmanager.com/gtm.js"></script>

为什么我们使用双斜杠(//)代替 http:// <来自beginig绝对网址的/ code>或 https:// ?有什么不同?

Why we use double slash ( // ) instead http:// or https:// from beginig absolute url ? what's different ?

推荐答案

协议将从您所在的任何页面继承。如果您的网站可以在主页上使用不同的协议 - http ,例如在帐户页面上 https ,那么您不必担心可能会加载不安全的内容。

the protocol will be inherited from whichever page you're on. If your site can be on different protocols - http on the homepage, https on account pages, for example - then you won't have to worry about potentially loading "insecure content."

这篇关于为什么我们使用双斜杠而不是http的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆