Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 895
defrex Avatar asked Dec 01 '11 15:12

defrex


1 Answers

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.

like image 162
jValdron Avatar answered Oct 06 '22 01:10

jValdron