What is the effect of starting a url with "//", and leaving out "http:"

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?


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.

链接地址: http://www.djcxy.com/p/42220.html

上一篇: 绝对与相对网址

下一篇: 用“//”开始一个网址的效果是什么,而忽略了“http:”