---
title: "history对象back()、forward()、go()方法"
author: "deng131"
date: "2010-12-11T11:22:04Z"
tags: []
categories: ["Web前端"]
slug: "history-back-forward-go"
draft: false
lastmod: "2010-12-11T12:16:19Z"
id: 839467
url: "https://thinking80s.iteye.com/blog/839467"
---

history.back() 
功能：加载历史列表中的前一个URL（<span style="color:red">后退</span>）。

语法：history.back()

调用该方法的效果等价于点击后退按钮或调用history.go(-1)。
 
 history.forward() 
功能：加载历史列表中的下一个URL（<span style="color:red">前进</span>）。

语法：history.forward()

调用该方法的效果等价于点击前进按钮或调用history.go(1)。
 
 history.go() 
功能：加载历史列表中的某个具体的页面。

语法：history.go(number)

参数：
number：要访问的URL在History的URL列表中的相对位置.

<span style="color:red">-1代表前一个(forward)，0代表当前，1代表(back)后一个。</span> 
<span style="color:red">
1(向后) <----- 0(当前) -----> -1(向前) 
history.go(-1) == history.forward()
history.go(1)  == history.back()
history.current, history.next
</span>