Mac Developer Library

Developer

WebKit Framework Reference WebFrameLoadDelegate Protocol Reference

Options
Deployment Target:

On This Page
Language:

WebFrameLoadDelegate

Inheritance


Not Applicable

Conforms To


Not Applicable

Import Statement


Swift

import WebKit

Objective-C

@import WebKit;

Availability


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

WebView frame load delegates implement this informal protocol to be notified while frame loads are in progress. Delegates are notified when a frame load starts, when a page title or icon is loaded, when a redirect occurs, when a data source is committed, and when the change is complete. The webView:didStartProvisionalLoadForFrame: method is invoked when a frame load starts, and the webView:didFinishLoadForFrame: method is invoked when the change is done. However, depending on the content being loaded, some of the other methods defined in this protocol may be invoked multiple times. All the methods in this protocol are optional.

  • Invoked when a page load is in progress in a given frame.

    Declaration

    Swift

    func webView(_ sender: WebView!, didStartProvisionalLoadForFrame frame: WebFrame!)

    Objective-C

    - (void)webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame

    Parameters

    sender

    The web view containing the frame.

    frame

    The frame being loaded.

    Discussion

    This method is invoked when a new client request is made by sender to load a provisional data source for frame. This method may be invoked after sending loadRequest: to a WebFrame object or as a consequence of the user clicking a link displayed in a web frame view. Delegates might implement this method to notify the user that a request is in progress. Additional information about the request can be obtained from the data source of frame.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

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

    Available in OS X v10.2.7 and later.

  • Invoked when a page load completes.

    Declaration

    Swift

    func webView(_ sender: WebView!, didFinishLoadForFrame frame: WebFrame!)

    Objective-C

    - (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame

    Parameters

    sender

    The web view containing the frame.

    frame

    The frame being loaded.

    Discussion

    This method is invoked when a location request for frame has completed; that is, when all the resources are done loading. Additional information about the request can be obtained from the data source of frame.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

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

    Available in OS X v10.2.7 and later.

  • Invoked when content starts arriving for a page load.

    Declaration

    Swift

    func webView(_ sender: WebView!, didCommitLoadForFrame frame: WebFrame!)

    Objective-C

    - (void)webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame

    Parameters

    sender

    The web view containing the frame.

    frame

    The frame being loaded.

    Discussion

    This method is invoked when a data source transitions from a provisional to committed state—that is, once the data source of frame has received one byte or more of data. This method is invoked after a webView:didStartProvisionalLoadForFrame: message but before a webView:didFinishLoadForFrame: message is sent to the delegate.

    In some cases, a single frame load may be committed more than once. This happens in the case of multipart/x-mixed-replace, also known as a “server push.” In this case, a single frame load results in multiple documents loaded in sequence. This method is invoked once for each document that is successfully loaded.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

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

    Available in OS X v10.2.7 and later.

  • Invoked when a frame will be closed.

    Declaration

    Swift

    func webView(_ sender: WebView!, willCloseFrame frame: WebFrame!)

    Objective-C

    - (void)webView:(WebView *)sender willCloseFrame:(WebFrame *)frame

    Parameters

    sender

    The web view containing the frame.

    frame

    The frame being loaded.

    Discussion

    Invoked right before WebKit is done with frame and the objects it owns.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

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

    Available in OS X v10.2.7 and later.

  • Invoked when the scroll position within a frame changes.

    Declaration

    Swift

    func webView(_ sender: WebView!, didChangeLocationWithinPageForFrame frame: WebFrame!)

    Objective-C

    - (void)webView:(WebView *)sender didChangeLocationWithinPageForFrame:(WebFrame *)frame

    Parameters

    sender

    The web view containing the frame.

    frame

    The frame being loaded.

    Discussion

    Typically, invoked when the user clicks on an anchor within a page. Additional information about the request can be obtained from the data source of frame.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

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

    Available in OS X v10.2.7 and later.

  • Invoked when the page title of a frame loads or changes.

    Declaration

    Swift

    func webView(_ sender: WebView!, didReceiveTitle title: String!, forFrame frame: WebFrame!)

    Objective-C

    - (void)webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame

    Parameters

    sender

    The web view containing the frame.

    title

    The newly loaded title.

    frame

    The frame being loaded.

    Discussion

    This method may be invoked multiple times before all resources for frame are completely loaded. Delegates might implement this message to display the page title to the user.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

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

    Available in OS X v10.2.7 and later.

  • Invoked when a page icon changes.

    Declaration

    Swift

    func webView(_ sender: WebView!, didReceiveIcon image: NSImage!, forFrame frame: WebFrame!)

    Objective-C

    - (void)webView:(WebView *)sender didReceiveIcon:(NSImage *)image forFrame:(WebFrame *)frame

    Parameters

    sender

    The web view containing the frame.

    image

    The page icon for a data source.

    frame

    The frame being loaded.

    Discussion

    This method may be invoked multiple times before all resources for frame are completely loaded. Sometimes a page uses a default icon or stored image that changes when the actual images is loaded.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

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

    Available in OS X v10.2.7 and later.

  • Invoked when a frame’s scripting object for a page is available. (Use the webView:didClearWindowObject:forFrame: method instead.)

    Declaration

    Objective-C

    - (void)webView:(WebView *)sender windowScriptObjectAvailable:(WebScriptObject *)windowScriptObject

    Parameters

    sender

    The web view containing the frame.

    windowScriptObject

    The window object in the scripting environment.

    Discussion

    This method is invoked before the page is actually loaded.

    Import Statement

    Objective-C

    @import WebKit;

    Availability

    Available in OS X v10.3.9 and later.

    Deprecated in OS X v10.4.11.

  • Invoked when the JavaScript window object in a frame is ready for loading.

    Declaration

    Swift

    func webView(_ sender: WebView!, didClearWindowObject windowObject: WebScriptObject!, forFrame frame: WebFrame!)

    Objective-C

    - (void)webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)windowObject forFrame:(WebFrame *)frame

    Parameters

    sender

    The web view sending this message.

    windowObject

    The cleared JavaScript window object.

    frame

    The frame containing the JavaScript window object.

    Discussion

    Use this method to set custom properties on the window object before the page is actually loaded. Every time a frame loads or is reloaded all DOM properties are cleared from the window object so the new page has a fresh window object to use. If the page you are loading depends on specific window object properties to exist, they should be added at this point before any scripts are executed.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.4.11 and later.