Location 객체
Location 객체는 문서의 주소와 관련된 객체로 Window 객체의 프로퍼티
URL 가져오기
<!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>URL 변경하기
Last updated