Nyx*_*nyx 21 url port http relative-path
我们都熟悉相对路径:./images/hello.jpg从http://www.domain.com/hey链接到的相对路径http://www.domain.com/hey/images/hello.jpg.
问题:你如何说明你到达http://www.domain.com:1234时的相对路径http://www.domain.com/hey?
pet*_*erp 20
这可以通过设置window.location.port属性使用JavaScript来实现.
<a href="#" onclick="javascript:window.location.port=8080">go</a>
Run Code Online (Sandbox Code Playgroud)
Ada*_*man 19
您不能在相对URL中更改权限的任何部分(即主机:端口部分).见中描述的算法部分5.2.2的RFC 3986,看相对URL如何解释.需要注意的重要一点是,只需从基本URL或正在解析的URL复制权限,永远不会解释权限的结构.这意味着您无法更改其任何部件,包括端口部件.
这是从RFC复制的伪代码中的算法:
-- The URI reference is parsed into the five URI components
--
(R.scheme, R.authority, R.path, R.query, R.fragment) = parse(R);
-- A non-strict parser may ignore a scheme in the reference
-- if it is identical to the base URI's scheme.
--
if ((not strict) and (R.scheme == Base.scheme)) then
undefine(R.scheme);
endif;
if defined(R.scheme) then
T.scheme = R.scheme;
T.authority = R.authority;
T.path = remove_dot_segments(R.path);
T.query = R.query;
else
if defined(R.authority) then
T.authority = R.authority;
T.path = remove_dot_segments(R.path);
T.query = R.query;
else
if (R.path == "") then
T.path = Base.path;
if defined(R.query) then
T.query = R.query;
else
T.query = Base.query;
endif;
else
if (R.path starts-with "/") then
T.path = remove_dot_segments(R.path);
else
T.path = merge(Base.path, R.path);
T.path = remove_dot_segments(T.path);
endif;
T.query = R.query;
endif;
T.authority = Base.authority;
endif;
T.scheme = Base.scheme;
endif;
T.fragment = R.fragment;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14016 次 |
| 最近记录: |