History.back()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

History.back() 메서드는 브라우저가 세션 기록의 바로 뒤 페이지로 이동하도록 지시합니다. history.go(-1)와 같습니다. 이전 페이지가 없는 경우 아무것도 하지 않습니다.

이 메서드는 비동기적입니다. popstate 이벤트 처리기를 통해 탐색 완료 시점을 알 수 있습니다.

구문

js
history.back();

예제

다음 예제는 클릭했을 때 뒤로 가는 버튼을 생성합니다.

HTML

html
<button id="go-back">뒤로 가기!</button>

JavaScript

js
document.getElementById("go-back").addEventListener("click", () => {
  window.history.back();
});

명세

Specification
HTML
# dom-history-back-dev

브라우저 호환성

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
back

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

같이 보기