창 위치
창 위치 개체
위치 개체 에는 현재 URL에 대한 정보가 포함되어 있습니다 .
위치 개체 는 창 개체 의 속성입니다 .
위치 개체 는 다음 을 사용하여 액세스합니다.
window.location
아니면 그냥location
예
let origin = window.location.origin;
let origin = location.origin;
위치 개체 속성
Property | Description |
---|---|
hash | Sets or returns the anchor part (#) of a URL |
host | Sets or returns the hostname and port number of a URL |
hostname | Sets or returns the hostname of a URL |
href | Sets or returns the entire URL |
origin | Returns the protocol, hostname and port number of a URL |
pathname | Sets or returns the path name of a URL |
port | Sets or returns the port number of a URL |
protocol | Sets or returns the protocol of a URL |
search | Sets or returns the querystring part of a URL |
위치 개체 메서드
Method | Description |
---|---|
assign() | Loads a new document |
reload() | Reloads the current document |
replace() | Replaces the current document with a new one |