gpt4 book ai didi

javascript - 将绝对路径转换为相对路径

转载 作者:行者123 更新时间:2023-12-01 02:35:20 24 4
gpt4 key购买 nike

通过 javascript 或 jquery 将绝对路径转换为相对路径的最佳方法是什么?

例如考虑如下:

"http://localhost:2011/Content/Images/Product/Large/3.jpg" 

 "/Content/Images/Product/Large/3.jpg" 

最佳答案

使用 <a> 的技巧元素包含位置属性。

$("<a href='http://localhost:2011/Content/Images/Product/Large/3.jpg'>")
.prop("pathname");

关于javascript - 将绝对路径转换为相对路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7259745/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com