Front/JS & jQuery

[js] location 속성별 설명

오선지♬ 2025. 7. 14. 20:03
728x90
반응형

 

속성  설명 예시 (https://example.com/customer/page.html?page=1#section1)
location.href 전체 URL 문자열 (읽기/쓰기 가능) "https://example.com/customer/page.html?page=1#section1"
location.origin 프로토콜 + 호스트 + 포트 번호 "https://example.com"
location.pathname 호스트 뒤의 경로 부분 "/customer/page.html"
location.search 쿼리 문자열 (물음표 포함) "?page=1"
location.hash 해시(anchor) (샵 포함) "#section1"
location.protocol 프로토콜 "https:"
location.hostname 호스트 이름(도메인) "example.com"
location.port 포트 번호 (기본 포트면 빈 문자열) "" 또는 "443" 등
728x90
반응형