티스토리 뷰

navigator와 비슷하게, location 객체를 사용하여 해당 문서의 정보 또한 확인할 수 있다.

 


<!DOCTYPE html>
<html lang="ko">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>location Object</title>
	<link rel="stylesheet" href="css/location.css">
</head>
<body>	
	<div id = "container">
		<script>
			document.write("이 문서의 위치(URL) : " + location.href + "<br/>");
			document.write("이 문서의 호스트 : " + location.host + "<br/>");
			document.write("이 문서의 프로토콜 : " + location.protocol + "<br/>");
		</script>
		
	</div>
</body>
</html>

Comments