window.history 개체는 웹 브라우저의 다음 페이지로 돌아가거나 다음 페이지로 이동하는 데 사용됩니다. 그것은 브라우저의 기록을 가지고 있으며 다음 두 가지 방법과 함께 제공됩니다 -
- history.back − 이전 URL로 이동
- history.next − 다음 URL로 이동
예시
다음 코드를 실행하여 JavaScript에서 window.history 개체를 사용하는 방법을 배울 수 있습니다. −
<!DOCTYPE html>
<html>
<body>
<script>
function backPage() {
window.history.back()
}
function nextPage() {
window.history.next()
}
</script>
<input type="button" value="Previous URL" onclick="backPage()">
<input type="button" value="Next URL" onclick="nextPage()">
</body>
</html>