针对URL浏览器支持双斜线开始 [英] Browser support for URLs beginning with double slash

查看:199
本文介绍了针对URL浏览器支持双斜线开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近见过没有协议中使用的一些链接。它似乎并不太难理解 - 我认为这是一个伟大的想法,pretty直观

I've recently seen a few links used without a protocol. It didn't seem too difficult to understand - I think it's a great idea and pretty intuitive.

对于那些你不知道,使用URL像 // example.com/script.js 将指向为的http://例子.COM /的script.js https://example.com/script.js 根据URL是否不是从起源 HTTP HTTPS URL。包括HTTP脚本或图片来自一个HTTPS页面可以是一个安全问题,例如,所以这个解决了,而无需在code需要进行协议检测。

For those of you unaware, using a URL like //example.com/script.js will point to either http://example.com/script.js or https://example.com/script.js depending on whether or not the URL originates from a http or https URL. Including http scripts or images from a https page can be a security concern, for example, so this solves that without the need for protocol detection in your code.

我的问题是,什么样的浏览器/ OS的支持是有呢?它是安全生产中使用?这当然会让事情变得更简单。

My question is, what sort of browser/OS support is there for it? Is it safe to use in production? It would certainly make things a bit easier.

简单的例子,测试:
HTTP://$c$ctester.org/916c6916

编辑:
就在跟进,我一直在使用,现在这种在生产中很多事情我公司的广告服务器没有问题了几年。

Just a follow up that I've been using this for my company's ad server in production for many things without issue for a couple years now.

推荐答案

本的行为是 RFC的一部分,1808 (第四节)大约是16岁,所以每一个主要的浏览器应该(和不)支持此功能。

This behavior was part of RFC 1808 (Section 4) which is about 16 years old, so every major browser should (and does) support this.

不幸的是,还有的与IE7和-8 一个bug,这将使他们下载资源的两倍如果协议相对URL是链接上使用 @import - 这不应该是一个大问题,但丑,应该牢记这一点。

Sadly, there's a bug with IE7 and -8 that will make them download the resources twice if a protocol-relative URL is used on a link or @import - which shouldn't be a big problem, but is ugly and should be kept in mind.

这篇关于针对URL浏览器支持双斜线开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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