Class

Web​Frame

A Web​Frame object encapsulates the data displayed in a Web​Frame​View object. There is one Web​Frame object per frame displayed in a Web​View. An entire webpage is represented by a hierarchy of Web​Frame objects in which the root object is called the main frame.

Overview

Each Web​Frame also has a Web​Data​Source object that manages the loading of frame content. You use the load(_:​) 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 Web​Frame. Some of the predefined frame names are: “_self”, “_current”, “_parent”, and “_top.” See find​Named(_:​) 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.

Symbols

Initializing Frames

init!(name:​ String!, web​Frame​View:​ Web​Frame​View!, web​View:​ Web​View!)

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

Loading Content

func load(URLRequest!)

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

func reload()

Reloads the initial request passed as an argument to load(_:​).

func reload​From​Origin()

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

func stop​Loading()

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

func load​HTMLString(String!, base​URL:​ URL!)

Sets the main page contents and base URL.

func load(Data!, mime​Type:​ String!, text​Encoding​Name:​ String!, base​URL:​ URL!)

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

func load(Web​Archive!)

Loads an archive into the web frame.

Getting the Data Source

var provisional​Data​Source:​ Web​Data​Source!

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

var parent:​ Web​Frame!

The web frame’s parent web frame.

var child​Frames:​ [Any]!

The frames of the web frame’s immediate children.

var frame​View:​ Web​Frame​View!

The web frame’s view object.

var web​View:​ Web​View!

The view object that manages the web frame.

Finding Frames

func find​Named(String!)

Returns a web frame that matches the given name.

var name:​ String!

The web frame’s name.

Getting DOM Objects

var dom​Document:​ DOMDocument!

The web frame’s DOM document.

var frame​Element:​ DOMHTMLElement!

The web view’s DOM frame element.

var global​Context:​ JSGlobal​Context​Ref!

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

var java​Script​Context:​ JSContext!

The frame's global JavaScript execution context.

Relationships

Inherits From

See Also