<!--
{
  "availability" : [
    "macOS: 10.4.0 - 10.14.0"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WebBackForwardList",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(cs)WebBackForwardList"
  },
  "title" : "WebBackForwardList"
}
-->

# WebBackForwardList

A `WebBackForwardList` object maintains a list of visited pages used to go back and forward to the most recent page. A `WebBackForwardList` object maintains only the list data—it does not perform actual page loads (in other words, it does not make any client requests). If you need to perform a page load, see the [`load(_:)`](/documentation/WebKit/WebFrame/load(_:)-47p2s) method in [`WebFrame`](/documentation/WebKit/WebFrame) to find out how to do this.

```
class WebBackForwardList
```

## Overview

Items are typically inserted in a back-forward list in the order they are visited. A `WebBackForwardList` object also maintains the notion of the current item (which is always at index `0`), the preceding item (which is at index `-1`), and the following item (which is at index `1`). The [`goBack()`](/documentation/WebKit/WebBackForwardList/goBack()) and [`goForward()`](/documentation/WebKit/WebBackForwardList/goForward()) methods move the current item backward or forward by one. The [`go(to:)`](/documentation/WebKit/WebBackForwardList/go(to:)) method sets the current item to the specified item. All other methods that return [`WebHistoryItem`](/documentation/WebKit/WebHistoryItem) objects do not change the value of the current item, they just return the requested item or items. You can also limit the number of history items stored in the back-forward list using [`capacity`](/documentation/WebKit/WebBackForwardList/capacity).

`WebBackForwardList` objects also control the number of pages cached. You can turn page caching off by setting the page cache size to `0` using the [`pageCacheSize()`](/documentation/WebKit/WebBackForwardList/pageCacheSize()) method, or limit the number of pages cached by passing a value greater than 0.

## Topics

### Adding and Removing Items

[`-  addItem:`](/documentation/WebKit/WebBackForwardList/add(_:))

Inserts an item into the back-forward list, immediately after the current item.

### Moving Backward and Forward

[`-  goBack`](/documentation/WebKit/WebBackForwardList/goBack())

Moves backward one item in the back-forward list.

[`-  goForward`](/documentation/WebKit/WebBackForwardList/goForward())

Moves forward one item in the back-forward list.

[`-  goToItem:`](/documentation/WebKit/WebBackForwardList/go(to:))

Makes the specified item in the back-forward list the current item.

### Querying the Back-Forward List

[`backItem`](/documentation/WebKit/WebBackForwardList/backItem)

The item that precedes the current item in the back-forward list.

[`backListCount`](/documentation/WebKit/WebBackForwardList/backListCount)

The number of items that precede the current item in the back-forward list.

[`-  backListWithLimit:`](/documentation/WebKit/WebBackForwardList/back(withLimit:))

Returns the items that precede the current item in the back-forward list, up to the specified number of items.

[`-  containsItem:`](/documentation/WebKit/WebBackForwardList/contains(_:))

Returns a Boolean value indicating whether the back-forward list contains the specified item.

[`currentItem`](/documentation/WebKit/WebBackForwardList/currentItem)

The current item in the back-forward list.

[`-  itemAtIndex:`](/documentation/WebKit/WebBackForwardList/item(at:))

Returns the item at the specified index in the back-forward list.

[`forwardItem`](/documentation/WebKit/WebBackForwardList/forwardItem)

The item that follows the current item in the back-forward list.

[`forwardListCount`](/documentation/WebKit/WebBackForwardList/forwardListCount)

The number of items that follow the current item in the back-forward list.

[`-  forwardListWithLimit:`](/documentation/WebKit/WebBackForwardList/forwardList(withLimit:))

Returns the items that follow the current item in the back-forward list, up to the specified number of items.

### Page Caching

[`-  pageCacheSize`](/documentation/WebKit/WebBackForwardList/pageCacheSize())

Returns the maximum number of pages that the receiver can cache.

[`-  setPageCacheSize:`](/documentation/WebKit/WebBackForwardList/setPageCacheSize(_:))

Sets the maximum number of pages the receiver can cache.

### Setting Attributes

[`capacity`](/documentation/WebKit/WebBackForwardList/capacity)

The maximum number of items that the back-forward list can contain.

## See Also

  [WebKit Objective-C Programming Guide](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/DisplayWebContent/DisplayWebContent.html#//apple_ref/doc/uid/10000164i)

## Relationships

### Conforms To

[`Hashable`](/documentation/Swift/Hashable)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`CVarArg`](/documentation/Swift/CVarArg)

[`Equatable`](/documentation/Swift/Equatable)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)