速记http:// as //用于脚本和链接标签?任何人看到/使用此之前? [英] shorthand http:// as // for script and link tags? anyone see / use this before?

查看:186
本文介绍了速记http:// as //用于脚本和链接标签?任何人看到/使用此之前?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题如下:



如果您使用addthis(分享按钮)查看任何网站...



一旦你漂浮在addthis按钮上,并且所有需要的资源加载都使用firebug或chrome检查器查看文档主体(而不是源代码,坐在屏幕上的实际文档...对象检查员)。您会注意到addthis自动加载的其他资源如下所示:

 < script type =text / javascript SRC =// s7.addthis.com/static/r07/menu78.js\"></script> 
< link rel =stylesheettype =text / csshref =// s7.addthis.com/static/r07/widget61.cssmedia =all>

以上标记中的http://的简短处理是什么?



有人曾经使用过这个吗?它有一个'官方'的名字吗?如何跨浏览器兼容这种短交易协议的方法?



是的,我明白这将打破爬行者/ SEO的事情,但我正在考虑开始使用这种情况是无法访问的情况下(主要是,js处理的东西)机器人。



好或坏主意?

>解决方案

// 开始一个URL意味着使用不同的服务器,但保持相同的方案 b
$ b

因此,如果您从 https://example.com/ 加载 // example.net/script / code>它会得到 https://example.net/script ,而如果你从 http://例子中加载它。 com / 它会得到 http://example.net/script



另一方面,如果你从 file:// c:/Users/You/Documents/test.html 加载它,那么它可能不会解析为任何有用的东西。如果使用此语法,请确保使用本地Web服务器进行开发(并访问 http:// localhost / )。



这是URI的标准部分,它得到了很好的支持,通常被称为scheme relative URIs。


the question is as follows:

if you take a look at any site using addthis (the share button)...

once you float over the addthis button, and all of the required assets load take a look at the body of the document using firebug or chrome inspector (not the source, the actual document that is sitting on your screen... the object inspector). you will notice that the additional assets loaded automatically by addthis look something like this:

<script type="text/javascript" src="//s7.addthis.com/static/r07/menu78.js"></script>
<link rel="stylesheet" type="text/css" href="//s7.addthis.com/static/r07/widget61.css" media="all">

what is this short handing of http:// in the above tags?

has anyone used this before? does it have an 'official' name? how cross browser compatible is this method of short handing the http protocal?

yes, i understand this will break things as far as crawlers / seo go, but i am thinking about starting to use this in situations that are inaccessible (mainly, js handled stuff) to bots.

good or bad idea?

解决方案

Starting a URL with // means "Use a different server but keep the same scheme"

So if you load //example.net/script from https://example.com/ it will get https://example.net/script, while if you load it from http://example.com/ it will get http://example.net/script.

If, on the other hand, you load it from file://c:/Users/You/Documents/test.html then it will probably not resolve to anything useful. Make sure you do development with a local web server (and access http://localhost/) if you use this syntax.

This is a standard part of URIs, it well supported, and is usually known as "scheme relative URIs"

这篇关于速记http:// as //用于脚本和链接标签?任何人看到/使用此之前?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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