简体   繁体   English

HTML电话链接可以接受值中的空格吗?

[英]Can a HTML telephone link accept spaces in the value?

Is there anything wrong or problematic with including spaces as well as a plus symbol (for the international code) in a telephone link? 在电话链接中包含空格以及plus (国际代码)是否有任何错误或问题? Example: 例:

<a href="tel:+46 000 00 00 00">+46 000 00 00 00</a>

(I replaced the actual number I want to use with 0s here) (我在这里用0替换了我想要使用的实际数字)

HTML is irrelevant here. HTML在这里无关紧要。 A URL is a URL no matter where you put it. 无论您将URL放在何处,URL都是URL。

The relevant spec says: 相关规范说:

even though ITU-T E.123 [E.123] recommends the use of space characters as visual separators in printed telephone numbers, "tel" URIs MUST NOT use spaces in visual separators to avoid excessive escaping. 尽管ITU-T E.123 [E.123]建议在打印的电话号码中使用空格字符作为可视分隔符,但“tel”URI不得在可视分隔符中使用空格以避免过度转义。

So " no ". 所以“ ”。

Even if a space was allowed, the general rules for URLs would mean that you would have to replace it with %20 (hence the comment about excessive escaping). 即使允许使用空格,URL的一般规则也意味着您必须将其替换为%20 (因此有关过度转义的注释)。

Yes it is incorrect to add spaces in telephone numbers on href , according to RFC 3966 (The tel URI for Telephone Numbers): 是的,根据RFC 3966 (电话号码的电话号码)在href上的电话号码中添加空格是不正确的:

5.1.1. 5.1.1。 Separators in Phone Numbers 电话号码中的分隔符

Phone numbers MAY contain visual separators. 电话号码可能包含可视分隔符。 Visual separators ('visual-separator') merely aid readability and are not used for URI comparison or placing a call ... "tel" URIs MUST NOT use spaces in visual separators ... 可视分隔符('visual-separator')仅仅具有可读性,不用于URI比较或发出调用... “tel”URI不得在可视分隔符中使用空格 ...

As you can see, the RFC clearly states: "tel" URIs MUST NOT use spaces in visual separators . 如您所见,RFC明确指出: “tel”URI不得在可视分隔符中使用空格

there is a full description here in another question. 在另一个问题中有完整的描述。
href="tel:" and mobile numbers href =“tel:”和手机号码

youcan have whatever number format your phone supports. 你可以拥有手机支持的任何数字格式。 there is no problem with "+" sign you use. 您使用的“+”符号没有问题。 but spaces not work in scarce situations. 但空间不适用于稀缺的情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM