Reputation: 931
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
"/Content/Images/Product/Large/3.jpg"
Upvotes: 2
Views: 3809
Reputation: 154818
Use the trick that <a>
elements contain location properties.
$("<a href='http://localhost:2011/Content/Images/Product/Large/3.jpg'>")
.prop("pathname");
Upvotes: 6