javascript 현재 경로 현재 프로토콜등 구하기

HYEONG HWAN, MUN/ 10월 24, 2014/ 미분류/ 0 comments

https://blog.lael.be/post/400

만약 당신이 지금
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);
} 

Leave a Comment

작성하신 댓글은 관리자의 수동 승인 후 게시됩니다.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
*
*