Document.location
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015년 7월.
Document.location 은 Location 객체를 반환하는 읽기 전용 속성입니다. Location은 document의 URL에 대한 정보를 포함하고 해당 URL을 변경하거나 다른 URL을 로딩하는 메서드를 제공합니다.
Document.location은 읽기 전용 Location 객체지만, 문자열을 할당할 수도 있습니다. 즉, 대부분의 경우에 document.location을 문자열처럼 사용할 수 있습니다. document.location = 'http://www.example.com'은 document.location.href = 'http://www.example.com'와 동의어입니다. 만약 다른 문자열을 할당한다면 브라우저가 할당된 웹사이트를 로드합니다.
URL을 문자열로 가져오려면 읽기 전용 속성인 document.URL도 사용할 수 있습니다.
만약 현재 document가 브라우저 맥락이 아니라면 null을 반환합니다.
값
Location 객체
예제
js
console.log(document.location);
// Location 객체를 console에 출력
명세서
| Specification |
|---|
| HTML> # the-location-interface> |
브라우저 호환성
Loading…
같이 보기
- 반환 값의 인터페이스
Location. - 비슷한 정보지만 browsing context에 속한
Window.location.