JAVASCRIPT

JAVASCRIPT URL 주소 가져오기

JDK's blog 2015. 11. 30. 22:09

안녕하세요. URL주소를 가져오는 방법을 알려드릴께요

 

1
2
3
4
5
6
7
8
9
<script>
    window.onload = function(){
        //전체주소
        console.log("url : "+location.href);
 
        //http:, localhost:port번호, index.html ?test=tttt 순으로 나누어져 있습니다.
        console.log("url : "+location.protocol+"//"+location.host+""+location.pathname+""+location.search);
    }
</script>
cs