<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
</head>
<body>
<h1>Location 객체</h1>
<h2>url전체(href)</h2>
<script>
document.write(location.href);
</script>
<h2>protocol</h2>
<script>
document.write(location.protocol);
</script>
<h2>host</h2>
<script>
document.write(location.host);
</script>
<h2>port</h2>
<script>
document.write(location.port);
</script>
<h2>pathname</h2>
<script>
document.write(location.pathname);
</script>
<h2>search</h2>
<script>
document.write(location.search);
</script>
<h2>hash</h2>
<script>
document.write(location.hash);
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
</head>
<body>
<input type="button" value="change" onclick="fn_clickHandler('change')">
<input type="button" value="reload" onclick="fn_clickHandler('reload')">
<script>
function fn_clickHandler(value) {
if(value === 'change') {
// url 이동
location.href = 'https://www.naver.com/'
} else {
// 페이지 새로고
location.reload();
}
}
</script>
</body>
</html>