What is the effect of starting a url with “//”, an

2019-01-18 05:33发布

Possible Duplicate:
Absolute URLs omitting the protocol (scheme) in order to preserve the one of the current page

I recently noticed that the embed codes for the "like" and "tweet" buttons don't include the http protocol. For example:

<script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>

<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) {return;}
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=555";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

Why do they do this?

1条回答
女痞
2楼-- · 2019-01-18 06:03

Depending on the protocol used by your website, http, https, spdy, etc, it will use the same protocol than your website is using. In other words it will use the currently used protocol.

查看更多
登录 后发表回答