| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/WebKit.framework |
| Availability | Available in Mac OS X v10.2 with Safari 1.0 and later. Available in Mac OS X v10.2.7 and later. |
| Companion guide | |
| Declared in | WebFrame.h |
| Related sample code |
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.
– loadRequest:
– reload
– reloadFromOrigin
– stopLoading
– loadAlternateHTMLString:baseURL:forUnreachableURL:
– loadHTMLString:baseURL:
– loadData:MIMEType:textEncodingName:baseURL:
– loadArchive:
Returns the frames of the web frame’s immediate children.
- (NSArray *)childFrames
The web frame’s immediate children. Each child web frame is an instance of WebFrame and corresponds to an HTML frameset or iframe element.
WebFrame.hReturns the committed data source.
- (WebDataSource *)dataSource
The committed data source, or nil if the provisional data source is not done loading.
WebFrame.hReturns the web frame’s DOM document.
- (DOMDocument *)DOMDocument
The web frame’s DOM document.
Returns nil if the receiver doesn’t have a DOM document; for example, if it’s a standalone image.
WebFrame.hReturns a web frame that matches the given name.
- (WebFrame *)findFrameNamed:(NSString *)name
The name of a frame.
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.
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.
WebFrame.hReturns the web view’s DOM frame element.
- (DOMHTMLElement *)frameElement
The web view’s DOM frame element. Returns nil if the receiver is the main frame.
The returned object may be an instance of either DOMHTMLFrameElement, DOMHTMLIFrameElement or DOMHTMLObjectElement.
WebFrame.hReturns the web frame’s view object.
- (WebFrameView *)frameView
The web frame’s view object.
WebFrame.hReturns the global JavaScript execution context for bridging between the WebKit and JavaScriptCore C API.
- (JSGlobalContextRef)globalContext
The global JavaScript execution context.
WebFrame.hInitializes the receiver with a frame name, web frame view, and controlling web view.
- (id)initWithName:(NSString *)frameName webFrameView:(WebFrameView *)frameView webView:(WebView *)webView
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.
The view that displays this web frame—the view associated with the receiver.
The parent view that manages the main frame and its children.
An initialized web frame.
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.
WebFrame.hLoads alternate content for a frame whose URL is unreachable.
- (void)loadAlternateHTMLString:(NSString *)string baseURL:(NSURL *)URL forUnreachableURL:(NSURL *)unreachableURL
The string to use as the main page for the document.
A file that is used to resolve relative URLs within the document.
The URL for the alternate page content.
Use this method to display page-level loading errors in a web view. Typically, a WebFrameLoadDelegate or WebPolicyDelegate object invokes this method from these methods: webView:didFailProvisionalLoadWithError:forFrame: (WebFrameLoadDelegate), webView:decidePolicyForMIMEType:request:frame:decisionListener: (WebPolicyDelegate), or webView:unableToImplementPolicyWithError:frame: (WebPolicyDelegate). If invoked from one of these methods, the back-forward list is maintained.
WebFrame.hLoads an archive into the web frame.
- (void)loadArchive:(WebArchive *)archive
The archive to load.
WebFrame.hSets the main page contents, MIME type, content encoding, and base URL.
- (void)loadData:(NSData *)data MIMEType:(NSString *)MIMEType textEncodingName:(NSString *)encodingName baseURL:(NSURL *)URL
The data to use for the main page of the document.
The MIME type of the data.
The IANA encoding name (for example, “utf-8” or “utf-16”).
A file that is used to resolve relative URLs within the document.
WebFrame.hSets the main page contents and base URL.
- (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)URL
The string to use as the main page for the document.
Since the string is treated as a webpage with UTF-8 encoding, the default encoding for any script elements referenced by the HTML is also UTF-8. To avoid this, include a character set attribute on the script element.
A file that is used to resolve relative URLs within the document.
WebFrame.hConnects to a given URL by initiating an asynchronous client request.
- (void)loadRequest:(NSURLRequest *)request
A client request.
Creates a provisional data source that will transition to a committed data source once any data has been received. Use the dataSource method to check if a committed data source is available, and the stopLoading method to stop the load. This method is typically invoked on the main frame.
WebFrame.hReturns the web frame’s name.
- (NSString *)name
The web frame’s name.
WebFrame.hReturns the web frame’s parent web frame.
- (WebFrame *)parentFrame
The parent web frame, or nil if it has none.
WebFrame.hReturns the provisional data source.
- (WebDataSource *)provisionalDataSource
The provisional data source, or nil if either a load request is not in progress or a load request has completed.
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.
WebFrame.hReloads the initial request passed as an argument to loadRequest:.
- (void)reload
WebFrame.hPerforms an end-to-end revalidation using cache-validating conditionals if possible.
- (void)reloadFromOrigin
End-to-end reload may be necessary if the cache entry has become corrupted for some reason.
WebFrame.hStops any pending loads on the receiver’s data source, and those of its children.
- (void)stopLoading
This method does not change the state of the receiver—whatever content has been loaded is preserved.
WebFrame.hReturns the view object that manages the web frame.
- (WebView *)webView
The view object that manages the entire hierarchy of web frame objects that contains the receiver.
WebFrame.hReturns the JavaScript window object.
- (WebScriptObject *)windowObject
The JavaScript window object.
WebFrame.hLast updated: 2009-03-25