将当前 URL 添加到不完整的链接是标准的网络浏览器行为吗?
Is it standard web-browser behaviour to prepend the current URL to incomplete links?
如果网站包含不完整的 link,例如:
<a href="#my_div">Link</a>
<a href="?my_var=1">Link</a>
将 link 解释为当前 URL 并附加了 href 值是否是标准的、普遍的行为?
The HTML5 spec defines how [href]
attributes behave
The href attribute on a and area elements must have a value that is a valid URL potentially surrounded by spaces.
链接到:
A string is a valid URL potentially surrounded by spaces if, after stripping leading and trailing whitespace from it, it is a valid URL.
链接到:
A URL is a valid URL if it conforms to the authoring conformance requirements in the URL standard. [URL]
它链接到一个相当大的文本块,但我认为以下内容很重要:
Most of the URL-related terms used in the HTML specification (URL, absolute URL, relative URL, relative schemes, scheme component, scheme data, username, password, host, port, path, query, fragment, percent encode, get the base, and UTF-8 percent encode) can be straightforwardly mapped to the terminology of [RFC3986] [RFC3987].
至于您在问题中包含的 "incomplete link" 个示例。它们分别是 "fragment" 和 "query" 的示例,它们具有 .
的隐式相对 URL 表示当前 URL (注它不会合并查询字符串或文档片段标识符).
如果网站包含不完整的 link,例如:
<a href="#my_div">Link</a>
<a href="?my_var=1">Link</a>
将 link 解释为当前 URL 并附加了 href 值是否是标准的、普遍的行为?
The HTML5 spec defines how [href]
attributes behave
The href attribute on a and area elements must have a value that is a valid URL potentially surrounded by spaces.
链接到:
A string is a valid URL potentially surrounded by spaces if, after stripping leading and trailing whitespace from it, it is a valid URL.
链接到:
A URL is a valid URL if it conforms to the authoring conformance requirements in the URL standard. [URL]
它链接到一个相当大的文本块,但我认为以下内容很重要:
Most of the URL-related terms used in the HTML specification (URL, absolute URL, relative URL, relative schemes, scheme component, scheme data, username, password, host, port, path, query, fragment, percent encode, get the base, and UTF-8 percent encode) can be straightforwardly mapped to the terminology of [RFC3986] [RFC3987].
至于您在问题中包含的 "incomplete link" 个示例。它们分别是 "fragment" 和 "query" 的示例,它们具有 .
的隐式相对 URL 表示当前 URL (注它不会合并查询字符串或文档片段标识符).