본문 바로가기

명사 美 비격식 (무리 중에서) 아주 뛰어난[눈에 띄는] 사람[것]

JavaScript

자바스크립트에서 ${contextPath} 변수로 사용하기

원하는 변수값안에 아래의 함수를 적는다, 함수가 contextPath를 반환해준다.

var = getContextPath()

function getContextPath() {
 var hostIndex = location.href.indexOf( location.host ) + location.host.length;
 return location.href.substring( hostIndex, location.href.indexOf('/', hostIndex + 1) );
};