javascript 현재 경로 현재 프로토콜등 구하기
만약 당신이 지금
http://www.test.com/ver2/index.php?wr_id=4&bbs=free
라는 위치라면
location.protocol : http:
location.host : www.test.com (주소)
location.pathname : /ver2/index.php (경로)
location.search : ?wr_id=4&bbs=free (파라미터)
저는 보통 아래와 같이 사용합니다.
function doLogin(){ location.href='/bbs/login.php?url='+urlencode(location.pathname + location.search); }