반응형
● window.location
- 현재 페이지의 URL을 나타내는 객체
● 속성 종류
속성명 | 설명 |
href | 전체 URL 문자열 |
protocol | 마지막 ':'를 포함한 프로토콜 정보 |
host | ':'과 포트번호를 포함한 URL의 호스트명 |
hostname | ':'과 포트번호를 제외한 URL의 호스트명 |
port | 포트 번호 |
pathname | '/' 뒤 경로 |
search | '?' 뒤 쿼리스트링 |
● 예시
- https://search.naver.com/search.naver?where=nexearch&sm=top_hty&fbm=0&ie=utf8&query=javascript
속성 | 사용방법 | 결과 |
href | window.location.href | 'https://search.naver.com/search.naver?where=nexearch&sm=top_hty&fbm=0&ie=utf8&query=javascript' |
protocol | window.location. protocol | 'https:' |
host | window.location. host | 'search.naver.com' |
hostname | window.location. hostname | 'search.naver.com' |
port | window.location. port | '' |
pathname | window.location. pathname | '/search.naver' |
search | window.location. search | '?where=nexearch&sm=top_hty&fbm=0&ie=utf8&query=javascript' |
참고
- hi.anna - [Javascript] 현재 페이지 URL 가져오기
https://hianna.tistory.com/464
반응형
'Programming > Javascript' 카테고리의 다른 글
[Javascript] video 태그 관련 명령어 (0) | 2024.04.18 |
---|---|
[Javascript] null 병합 연산자(Nullish Coalescing Operator, ??) (2) | 2024.01.10 |
[Javascript] Cookie, jQuery로 로그인 ID 저장하기 기능 구현하기 (4) | 2023.12.07 |
[Javascript] jQuery TableDnD를 이용하여 테이블 순번 바꾸기 (2) | 2023.11.02 |
[Javascript] Debounce와 Throttle의 차이 (2) | 2023.11.01 |
댓글