본문 바로가기
프로그래밍/JavaScript

JavaScript History 객체

by zoo10 2013. 1. 5.

JavaScript Window History


window.history 객체는 브라우저의 히스토리 정보를 가지고 있습니다.


Window History

window.history 객체는 window prefix를 생략하고 사용할 수 있습니다.

To protect the privacy of the users, there are limitations to how JavaScript can access this object.

Some methods:

  • history.back() - 브라우저의 백버튼 누른 효과
  • history.forward() - 브라우저의 앞으로 번튼 누른 효과

Window History Back

history.back() 함수는 히스토리 목록에서 바로 이전 URL로 돌아가는 함수이다.

브라우저의 Back 버튼을 누른 것과 같다.

Example

페이지에 back 버튼 만들어 보기:

<html>
<head>
<script>
function goBack()
  {
  window.history.back()
  }
</script>
</head>
<body>

<input type="button" value="Back" onclick="goBack()" />

</body>
</html>



Window History Forward

history forward() 함수는 히스토리의 다음 URL로 페이지를 전환한다.

브라우저의 Forward 버튼을 누른 효과

Example

화면에 "앞으로" 버튼 달아보기

<html>
<head>
<script>
function goForward()
  {
  window.history.forward()
  }
</script>
</head>
<body>

<input type="button" value="Forward" onclick="goForward()" />

</body>
</html>


'프로그래밍 > JavaScript' 카테고리의 다른 글

JavaScript 타이밍 제어, Timing 이벤트  (2) 2013.01.05
JavaScript Number 객체  (0) 2013.01.05
JavaScript Date 객체  (2) 2013.01.05
JavaScript 배열 객체, Array  (2) 2013.01.05
JavaScript Location 객체  (0) 2013.01.05
JavaScript 스크린 객체  (0) 2013.01.05
JavaScript Navigator 객체  (0) 2013.01.05
JavaScript 브라우저 객체 모델 BOM  (2) 2013.01.05