HTML 참고서/HTML 생활코딩 Youtube
5.JavaScript Location
Or71nH
2020. 4. 12. 12:47
### 주소 가져오기 href
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script type="text/javascript">
console.log(location.toString(), location.href);
</script>
</body>
</html>
### 링크의 분석을 해보자
console.log(location);
// 출력 : https://opentutorials.org/module/904/6634?id=10#bookmark
console.log(
location.protocol, // 'http:' 이게 프로트콜
location.host, // 'opentutorials.org' 이거
location.port, // '8080' 도매인 뒤에 있음
location.pathname, // 'module/904/6634' 구체적인 위치
location.search, // '?id=10'
location.hash // '#bookmark'
)
### 리로딩
location.href = 'http://egoing.net';
// 이곳으로 보넴
location.reload();
//현제 웹페이지를 리로드함
location.href = 'location.href'
이또한 같다