Mac Developer Library

Developer

WebKit Framework Reference WebFrame Class Reference

Options
Deployment Target:

On This Page
Language:

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.

Each WebFrame also has a WebDataSource object that manages the loading of frame content. You use the loadRequest: 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 findFrameNamed: 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.

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

    Declaration

    Swift

    init!(name name: String!, webFrameView view: WebFrameView!, webView webView: WebView!)

    Objective-C

    - (instancetype)initWithName:(NSString *)frameName webFrameView:(WebFrameView *)view webView:(WebView *)webView

    Parameters

    frameName

    The frame name. Typically a custom name or nil (if none is specified). It would be inappropriate to use one of the predefined frame names described in findFrameNamed: as they have special meanings.

    view

    The view that displays this web frame—the view associated with the receiver.

    webView

    The parent view that manages the main frame and its children.

    Return Value

    An initialized web frame.

    Discussion

    Normally, you do not invoke this method directly. WebView objects automatically create the main frame and subsequent children when new content is loaded. Send a loadRequest: message to the main frame of a WebView to load web content.

    This method is the designated initializer for the WebFrame class.

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • The committed data source. (read-only)

    Declaration

    Swift

    var dataSource: WebDataSource? { get }

    Objective-C

    @property(nonatomic, readonly, strong) WebDataSource *dataSource

    Discussion

    nil if the provisional data source is not done loading.

    Availability

    Available in OS X v10.2 and later.

  • The provisional data source, or nil if either a load request is not in progress or a load request has completed. (read-only)

    Declaration

    Swift

    var provisionalDataSource: WebDataSource! { get }

    Objective-C

    @property(nonatomic, readonly, strong) WebDataSource *provisionalDataSource

    Discussion

    Use the loadRequest: method to initiate an asynchronous client request, which creates a provisional data source. The provisional data source transitions to a committed data source once any data is received.

    Availability

    Available in OS X v10.2 and later.

    See Also

    dataSource

  • The web frame’s parent web frame. (read-only)

    Declaration

    Swift

    var parentFrame: WebFrame! { get }

    Objective-C

    @property(nonatomic, readonly, strong) WebFrame *parentFrame

    Availability

    Available in OS X v10.2 and later.

    See Also

    childFrames

  • The frames of the web frame’s immediate children. (read-only)

    Declaration

    Swift

    var childFrames: [AnyObject]! { get }

    Objective-C

    @property(nonatomic, readonly, copy) NSArray *childFrames

    Discussion

    Each child web frame is an instance of WebFrame and corresponds to an HTML frameset or iframe element.

    Availability

    Available in OS X v10.2 and later.

    See Also

    parentFrame

  • The web frame’s view object. (read-only)

    Declaration

    Swift

    var frameView: WebFrameView! { get }

    Objective-C

    @property(nonatomic, readonly, strong) WebFrameView *frameView

    Availability

    Available in OS X v10.2 and later.

    See Also

    webView

  • The view object that manages the web frame. (read-only)

    Declaration

    Swift

    var webView: WebView! { get }

    Objective-C

    @property(nonatomic, readonly, strong) WebView *webView

    Availability

    Available in OS X v10.2 and later.

    See Also

    frameView

  • Returns a web frame that matches the given name.

    Declaration

    Swift

    func findFrameNamed(_ name: String!) -> WebFrame!

    Objective-C

    - (WebFrame *)findFrameNamed:(NSString *)name

    Parameters

    name

    The name of a frame.

    Return Value

    For predefined names, returns the receiver if name is “_self” or “_current”, returns the receiver’s parent frame if name is “_parent”, and returns the main frame if name is “_top”. Also returns the receiver if it is the main frame and name is either “_parent” or “_top.” For other names, this method returns the first frame that matches name. Returns nil if no match is found.

    Discussion

    This method searches the receiver and its descendents first, then the receiver’s parent and its children moving up the hierarchy until a match is found. If no match is found in the receivers hierarchy, this method will search for a matching frame in other main frame hierarchies.

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

    See Also

    name

  • name name Property

    The web frame’s name. (read-only)

    Declaration

    Swift

    var name: String! { get }

    Objective-C

    @property(nonatomic, readonly, copy) NSString *name

    Availability

    Available in OS X v10.2 and later.

  • The web frame’s DOM document. (read-only)

    Declaration

    Swift

    var DOMDocument: DOMDocument! { get }

    Objective-C

    @property(nonatomic, readonly, strong) DOMDocument *DOMDocument

    Discussion

    nil if the receiver doesn’t have a DOM document; for example, if it’s a standalone image.

    Availability

    Available in OS X v10.3 and later.

  • The web view’s DOM frame element. (read-only)

    Declaration

    Swift

    var frameElement: DOMHTMLElement! { get }

    Objective-C

    @property(nonatomic, readonly, strong) DOMHTMLElement *frameElement

    Availability

    Available in OS X v10.3 and later.

  • The global JavaScript execution context for bridging between the WebKit and JavaScriptCore C API. (read-only)

    Declaration

    Swift

    var globalContext: JSGlobalContextRef { get }

    Objective-C

    @property(nonatomic, readonly) JSGlobalContextRef globalContext

    Availability

    Available in OS X v10.5 and later.

  • The JavaScript window object. (read-only)

    Declaration

    Swift

    var windowObject: WebScriptObject! { get }

    Objective-C

    @property(nonatomic, readonly, strong) WebScriptObject *windowObject

    Availability

    Available in OS X v10.5 and later.