链接/ href只有参数(以问号开头)有效吗? [英] is link / href with just parameters (starting with question mark) valid?
问题描述
此链接是否有效?
< a href =?lang = en> eng< / a>
我知道浏览器会按照预期处理它,并且我知道空链接也没关系 - 但可以指定参数吗?
我很好奇,因为问号(?)只是大多数HTTP服务器(AFAIK)的一个约定,尽管我承认它是盛行的。
<所以,回顾一下:
-
所有浏览器都能正确解释它吗?
-
是RFC中的内容吗?
-
我可以预料到使用它会遇到一些麻烦吗?
更新:对点击的预期操作是重定向到同一页面,但使用不同的GET参数(上面的lang = en例如)。
是的,它是。 在具有明确定义的基本URL的对象中 - 现在,并不是说所有的浏览器都按照标准来实现它,但它看起来很像像这样应该是安全的。 Is this link valid? I know the browsers treat it as expected and I know the empty link would be ok too - but is it ok to specify just the parameters? I am curious because question mark ("?") is only a convention by most HTTP servers (AFAIK), though I admit it is a prevailing one. So, to recap: will all browsers interpret this correctly? is this in RFC? can I expect some trouble using this? UPDATE: the intended action on click is to redirect to the same page, but with different GET parameters ("lang=en" in above example). Yes, it is. Within an object with a well-defined base URL of RFC 3986 - Uniform Resource Identifier (URI): Generic Syntax restates the same, and adds more details, including the grammar: Now, that is not to say all browsers implement it according to the standard, but it looks like this should be safe. 这篇关于链接/ href只有参数(以问号开头)有效吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
您可以在RFC 1808 - 相对统一资源定位器:
Base:< URL:http:// a / b / c / d ; p?q#f>
相对URL将按以下方式解析:
5.1。正常示例
?y
= < URL:http:// a / b / c / d; p?y>
relative-ref = relative-part [?查询] [#片段]
relative-part =//权限path-abempty
/ path-absolute
/ path-noscheme
/ path -empty#;零字符
<a href="?lang=en">eng</a>
You can find it in RFC 1808 - Relative Uniform Resource Locators:
Base: <URL:http://a/b/c/d;p?q#f>
the relative URLs would be resolved as follows:5.1. Normal Examples
?y
= <URL:http://a/b/c/d;p?y>
relative-ref = relative-part [ "?" query ] [ "#" fragment ]
relative-part = "//" authority path-abempty
/ path-absolute
/ path-noscheme
/ path-empty #; zero characters