location 객체란 Windows 객체의 Property로 문서의 주소에 대한 객체이다.
해당 객체를 통해 원도우 문서에 대한 정보를 얻거나 수정할 수 있다.
원도우의 문서가 위치하는 Url GET 함수
console.log(location.toString(), location.href);
Url 변경
location.href = "http://egoing.net";
location = "http://egoing.net";
Url Parsing
Example : https://opentutorials.org:80/module/904/663#bookmark
1. location.protocol
console.log(location.protocol);
result : https:
2. location.host
console.log(location.host);
result : opentutorials.org
3. location.port
console.log(location.port);
result : undefined (80)
4. location.pathname
console.log(location.pathname)
result : /module/904/663
5. location.search
console.log(location.search)
result : ?id=10
6. location.hash
console.log(location.hash);
result : #bookmark
Url Reload
location.reload();
출처
location : https://opentutorials.org/module/904/6634
Location 객체 - 웹브라우저 JavaScript
Location 객체는 문서의 주소와 관련된 객체로 Window 객체의 프로퍼티다. 이 객체를 이용해서 윈도우의 문서 URL을 변경할 수 있고, 문서의 위치와 관련해서 다양한 정보를 얻을 수 있다. 현재 윈도
opentutorials.org