HTML DOM History 길이 속성은 현재 창의 History 목록에 있는 URL을 반환합니다.
구문
다음은 구문입니다 -
history.length
예시
HTML DOM History 길이 속성의 예를 살펴보겠습니다 -
<!DOCTYPE html>
<html>
<head>
<style>
body{
text-align:center;
}
.btn{
background-color:lightblue;
border:none;
height:2rem;
border-radius:50px;
width:60%;
margin:1rem auto;
}
.show{
font-size:2rem;
font-weight:bold;
color:orange;
}
</style>
</head>
<body>
<h1>History length Property Example</h1>
<button type="button" onclick="getHistoryLength()" class="btn">Click me to get History length
<div class="show"></div>
<script>
function getHistoryLength(){
var historyLength=history.length;
document.querySelector(".show").innerHTML = historyLength;
}
</script>
</body>
</html> 출력
이것은 다음과 같은 출력을 생성합니다 -

"파란색 ” 버튼을 누르면 현재 브라우저 창의 기록 길이를 볼 수 있습니다.
