JQUERY
JQUERY url 주소가져오기
JDK's blog
2015. 11. 30. 22:31
안녕하세요. 이번엔 JQUERY에서 URL을 가져오는 방법을 알려드리겠습니다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14 |
<!-- jquery를 불러옵니다. jquery.com download 페이지를 참조해주세요 -->
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script>
window.onload = function(){
//전체주소
console.log("url : "+$(location).attr('href'));
//http:, localhost:port번호, index.html ?test=tttt 순으로 나누어져 있습니다.
console.log("url : "+$(location).attr('protocol')+"//"+$(location).attr('host')+""+$(location).attr('pathname')+""+$(location).attr('search'));
}
</script> |
cs |