开发者

Converting absolute path to relative

What is best way to convert absolute path to relative path by javascript or jquery ?

for example consider as below :

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

to

 "/Con开发者_如何学Gotent/Images/Product/Large/3.jpg" 


Use the trick that <a> elements contain location properties.

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


Just use window.location.pathname

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜