절대 경로를 javascript 또는 jquery로 상대 경로로 변환하는 가장 좋은 방법은 무엇입니까?절대 경로를 상대 경로로 변환
예를 들어 다음과 같이 고려 :
"http://localhost:2011/Content/Images/Product/Large/3.jpg"
에
"/Content/Images/Product/Large/3.jpg"
절대 경로를 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");
훌륭한 트릭! 'pathname'prop를 설명하는 문서를 참조 할 수 있습니까? 우리가 의지 할 수있는 다른 소품은 무엇입니까? – abernier
@abernier : [여기에 목록이 있습니다.] (https://developer.mozilla.org/en/DOM/HTMLAnchorElement#Properties) HTML5라고 명시되어 있습니다. 나는 브라우저 간 지원에 대해 알지 못한다. – pimvdb