Deprecated: imwpcache\f884414bce24ee67f\f73723ec7b1919fa5::__construct(): Implicitly marking parameter $YECBGYFECGEAFWHA as nullable is deprecated, the explicit nullable type must be used instead in /www/wwwroot/www.chuangxiangniao.com/wp-content/plugins/imwpcache-dist/build/f884414bce24ee67ff73723ec7b1919fa5.php on line 2

Deprecated: imwpcache\f884414bce24ee67f\f73723ec7b1919fa5::__construct(): Implicitly marking parameter $BBWFDDBHHYHDXXAB as nullable is deprecated, the explicit nullable type must be used instead in /www/wwwroot/www.chuangxiangniao.com/wp-content/plugins/imwpcache-dist/build/f884414bce24ee67ff73723ec7b1919fa5.php on line 2
如何解析网页链接中的相对URL?_创想鸟

如何解析网页链接中的相对URL?

如何解析网页链接中的相对URL?

解析href路径中的相对url

当处理网页链接时,有时需要确定以相对路径指定的目标网址。以下是如何根据href路径判断最终URL网址:

例如,在以下网页中:

https://www.dataroma.com/m/holdings.php?m=BRK

包含如下表述:

≡

如何确定此链接的最终指向为何:

https://www.dataroma.com/m/hist/hist.php?f=BRK&s=AAPL

利用相对源URL

根据MDN文档,上述链接被称为相对于源的URL。源是location.origin,在本例中为https://www.dataroma.com。

通过将相对路径与源URL结合,可以获得最终的URL:

最终URL = 源 + 相对路径

https://www.dataroma.com + /m/hist/hist.php?f=BRK&s=AAPL= https://www.dataroma.com/m/hist/hist.php?f=BRK&s=AAPL

因此,该链接的最终指向为:

https://www.dataroma.com/m/hist/hist.php?f=BRK&s=AAPL

以上就是如何解析网页链接中的相对URL?的详细内容,更多请关注创想鸟其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/1559367.html

赞 (0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
Vue中如何去除浏览器默认的margin?
上一篇 2025年12月22日 04:41:23
为什么我的弹性盒布局子元素没有显示在 div 中?如何实现最后两个 div 右对齐?
下一篇 2025年12月22日 04:41:33

相关推荐

发表回复

登录后才能评论
关注微信