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

1

10

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?

Knout answered 1/12, 2011 at 15:34 Comment(3)
may be its adding http automatically....Lorenzoloresz
possible duplicate of Absolute URLs omitting the protocol (scheme) in order to preserve the one of the current page and many others such as this oneFiretrap
See also What are those URL's that are starting with // - that you can see within Google+ html source?Drying
M
9

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.

Mccluskey answered 1/12, 2011 at 15:35 Comment(1)
Also file:// and ftp:// and gopher://, etc.Beecham

© 2022 - 2024 — McMap. All rights reserved.