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

# WebFrame

A `WebFrame` object encapsulates the data displayed in a `WebFrameView` object. There is one `WebFrame` object per frame displayed in a `WebView`. An entire webpage is represented by a hierarchy of `WebFrame` objects in which the root object is called the **main frame**.

```
class WebFrame
```

## Overview

Each `WebFrame` also has a `WebDataSource` object that manages the loading of frame content. You use the [`load(_:)`](/documentation/WebKit/WebFrame/load(_:)-47p2s) method to initiate an asynchronous client request which will create a provisional data source. The provisional data source will transition to a committed data source once any data has been received.

There are some special, predefined, frame names that you can use when referring to or finding a `WebFrame`. Some of the predefined frame names are: “_self”, “_current”, “_parent”, and “_top.” See [`findNamed(_:)`](/documentation/WebKit/WebFrame/findNamed(_:)) for a description of their meaning. Frame names may also be specified in the HTML source, or set by clients.

However, the group name is an arbitrary identifier used to group related frames. For example, JavaScript running in a frame can access any other frame in the same group. It’s up to the application how it chooses to scope related frames.

## Topics

### Initializing Frames

[`-  initWithName:webFrameView:webView:`](/documentation/WebKit/WebFrame/init(name:webFrameView:webView:))

Initializes the receiver with a frame name, web frame view, and controlling web view.

### Loading Content

[`-  loadRequest:`](/documentation/WebKit/WebFrame/load(_:)-47p2s)

Connects to a given URL by initiating an asynchronous client request.

[`-  reload`](/documentation/WebKit/WebFrame/reload())

Reloads the initial request passed as an argument to [`load(_:)`](/documentation/WebKit/WebFrame/load(_:)-47p2s).

[`-  reloadFromOrigin`](/documentation/WebKit/WebFrame/reloadFromOrigin())

Performs an end-to-end revalidation using cache-validating conditionals if possible.

[`-  stopLoading`](/documentation/WebKit/WebFrame/stopLoading())

Stops any pending loads on the receiver’s data source, and those of its children.

[`-  loadAlternateHTMLString:baseURL:forUnreachableURL:`](/documentation/WebKit/WebFrame/loadAlternateHTMLString(_:baseURL:forUnreachableURL:))

Loads alternate content for a frame whose URL is unreachable.

[`-  loadHTMLString:baseURL:`](/documentation/WebKit/WebFrame/loadHTMLString(_:baseURL:))

Sets the main page contents and base URL.

[`-  loadData:MIMEType:textEncodingName:baseURL:`](/documentation/WebKit/WebFrame/load(_:mimeType:textEncodingName:baseURL:))

Sets the main page contents, MIME type, content encoding, and base URL.

[`-  loadArchive:`](/documentation/WebKit/WebFrame/load(_:)-6wkx6)

Loads an archive into the web frame.

### Getting the Data Source

[`dataSource`](/documentation/WebKit/WebFrame/dataSource)

The committed data source.

[`provisionalDataSource`](/documentation/WebKit/WebFrame/provisionalDataSource)

The provisional data source, or `nil` if either a load request is not in progress or a load request has completed.

### Getting Related Frames and Views

[`parentFrame`](/documentation/WebKit/WebFrame/parent)

The web frame’s parent web frame.

[`childFrames`](/documentation/WebKit/WebFrame/childFrames)

The frames of the web frame’s immediate children.

[`frameView`](/documentation/WebKit/WebFrame/frameView)

The web frame’s view object.

[`webView`](/documentation/WebKit/WebFrame/webView)

The view object that manages the web frame.

### Finding Frames

[`-  findFrameNamed:`](/documentation/WebKit/WebFrame/findNamed(_:))

Returns a web frame that matches the given name.

[`name`](/documentation/WebKit/WebFrame/name)

The web frame’s name.

### Getting DOM Objects

[`DOMDocument`](/documentation/WebKit/WebFrame/domDocument)

The web frame’s DOM document.

[`frameElement`](/documentation/WebKit/WebFrame/frameElement)

The web view’s DOM frame element.

[`globalContext`](/documentation/WebKit/WebFrame/globalContext)

The global JavaScript execution context for bridging between the WebKit and JavaScriptCore C API.

[`javaScriptContext`](/documentation/WebKit/WebFrame/javaScriptContext)

The frame’s global JavaScript execution context.

[`windowObject`](/documentation/WebKit/WebFrame/windowObject)

The JavaScript window object.

## 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

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

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

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

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

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

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

### 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)