开发者

Are there situations where omitting the protocol in http:// or https:// will fail to work in certain browsers? [duplicate]

This question already has answers here: 开发者_开发技巧 Closed 11 years ago.

Possible Duplicate:

Can I change all my links to just //?

I.e. if I do: //www.google.com it would point to http://www.google.com or https://www.google.com depending on what the current protocol is. Are there browsers that is reasonable to support where this doesn't work, if so which?


This would work on all browsers according to RFC 3986 Section 4.2. They call it relative reference.

Further more I have seen good JavaScript coders using it / recommending it

  1. The protocol-relative URL by Paul Irish
  2. Cripple the Google CDN’s caching with a single character by Dave Ward

Furthermore you can find related questions here and here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜