| 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 | WebView.h |
| Related sample code |
WebView is the core view class in the WebKit framework that manages interactions between the WebFrame and WebFrameView classes. To embed web content in your application, you just create a WebView object, attach it to a window, and send a loadRequest: message to its main frame.
Behind the scenes, WebFrame objects encapsulate the content contained in a single frame element. A hierarchy of WebFrame objects is used to model an entire webpage where the root is called the main frame. There is a WebFrameView object per WebFrame object used to display the frame content. Therefore, there is a parallel hierarchy of WebFrameView objects used to render an entire page. The WebView object is also the parent view of this hierarchy. You do not need to create WebFrame and WebFrameView objects directly. These objects are automatically created when the page loads, either programmatically or by the user clicking a link.
You customize your embedded web content by implementing WebView delegates to handle certain aspects of the process. WebView objects have multiple delegates because the process of loading a webpage is asynchronous and complicated if errors occur. All the WebView delegates use informal protocols so you only need to implement only the delegates and methods that define the behavior you wish to change—default implementations are already provided.
For example, you might want to implement the frame load and resource load delegates to monitor the load progress and display status messages. Applications that use multiple windows may want to implement a user interface delegate. See the individual informal delegate protocols for more details: WebFrameLoadDelegate Protocol Reference, WebPolicyDelegate Protocol Reference, WebResourceLoadDelegate Protocol Reference, and WebUIDelegate Protocol Reference.
Another way to monitor load progress with less control is to observe the WebViewProgressEstimateChangedNotification, WebViewProgressFinishedNotification, and WebViewProgressStartedNotification notifications. For example, you could observe these notifications to implement a simple progress indicator in your application. You update the progress indicator by invoking the estimatedProgress method to get an estimate of the amount of content that is currently loaded.
A WebView object is intended to support most features you would expect in a web browser except that it doesn’t implement the specific user interface for those features. You are responsible for implementing the user interface objects such as status bars, toolbars, buttons, and text fields. For example, a WebView object manages a back-forward list by default, and has goBack: and goForward: action methods. It is your responsibility to create the buttons that would send theses action messages. Note, there is some overhead in maintaining a back-forward list and page cache, so you should disable it if your application doesn’t use it.
You use a WebPreferences object to encapsulate the preferences of a WebView object, such as the font, text encoding, and image settings. You can modify the preferences for individual WebView objects or specify a shared WebPreferences object using the setPreferencesIdentifier: method. Use the setAutosaves: WebPreferences method to specify whether the preferences should be automatically saved to the user defaults database.
You can also extend WebKit by implementing your own document view and representation classes for specific MIME types. Use the registerViewClass:representationClass:forMIMEType: class method to register your custom classes with a WebView object.
– drawsBackground
– setDrawsBackground:
– setShouldUpdateWhileOffscreen:
– shouldUpdateWhileOffscreen
– setMaintainsBackForwardList:
– backForwardList
– canGoBack
– goBack
– goBack:
– canGoForward
– goForward
– goForward:
– goToBackForwardItem:
– downloadDelegate
– setDownloadDelegate:
– frameLoadDelegate
– setFrameLoadDelegate:
– policyDelegate
– setPolicyDelegate:
– resourceLoadDelegate
– setResourceLoadDelegate:
– UIDelegate
– setUIDelegate:
– isLoading
– selectedFrame
– setMainFrameURL:
– mainFrameURL
– mainFrameTitle
– mainFrameIcon
– mainFrameDocument
+ canShowMIMEType:
+ MIMETypesShownAsHTML
+ setMIMETypesShownAsHTML:
+ canShowMIMETypeAsHTML:
– supportsTextEncoding
– customTextEncodingName
– setCustomTextEncodingName:
– textSizeMultiplier
– setTextSizeMultiplier:
– userAgentForURL:
– applicationNameForUserAgent
– setApplicationNameForUserAgent:
– customUserAgent
– setCustomUserAgent:
+ URLFromPasteboard:
+ URLTitleFromPasteboard:
– pasteboardTypesForElement:
– pasteboardTypesForSelection
– writeElement:withPasteboardTypes:toPasteboard:
– writeSelectionWithPasteboardTypes:toPasteboard:
– isEditable
– setEditable:
– smartInsertDeleteEnabled
– setSmartInsertDeleteEnabled:
– isContinuousSpellCheckingEnabled
– setContinuousSpellCheckingEnabled:
– spellCheckerDocumentTag
– undoManager
– editingDelegate
– setEditingDelegate:
– editableDOMRangeForPoint:
– replaceSelectionWithNode:
– replaceSelectionWithText:
– replaceSelectionWithMarkupString:
– replaceSelectionWithArchive:
– deleteSelection
– moveToBeginningOfSentence:
– moveToBeginningOfSentenceAndModifySelection:
– moveToEndOfSentence:
– moveToEndOfSentenceAndModifySelection:
– selectSentence:
– toggleContinuousSpellChecking:
– toggleSmartInsertDelete:
– canMakeTextStandardSize
– makeTextStandardSize:
– maintainsInactiveSelection
– computedStyleForElement:pseudoElement:
– mediaStyle
– setMediaStyle:
– typingStyle
– setTypingStyle:
– styleDeclarationWithText:
– applyStyle:
Returns whether the receiver can display content of a given MIME type.
+ (BOOL)canShowMIMEType:(NSString *)MIMEType
The MIME type of the content.
YES if the receiver can display content of the specified MIME type where MIMEType is one of the standard types like “image/gif”; otherwise, NO.
WebView.hReturns whether the receiver interprets a MIME type as HTML.
+ (BOOL)canShowMIMETypeAsHTML:(NSString *)MIMEType
The MIME type of the content.
YES if the receiver interprets MIMEType as HTML; otherwise, NO.
WebView.hReturns a list of MIME types that WebKit renders as HTML.
+ (NSArray *)MIMETypesShownAsHTML
An array containing NSString objects that represent the MIME types WebKit attempts to render as HTML.
WebView.hAdds the specified URL scheme to the list of local schemes.
+ (void)registerURLSchemeAsLocal:(NSString *)scheme
The scheme to add to the list.
You need to register a scheme as local to access resources with file URLs and to have the same security checks as a local file.
WebView.hSpecifies the view and representation objects to be used for specific MIME types.
+ (void)registerViewClass:(Class)viewClass representationClass:(Class)representationClass forMIMEType:(NSString *)MIMEType
A class conforming to the WebDocumentView protocol that displays the specified MIME types.
The class conforming to WebDocumentRepresentation protocol that represents the specified MIME types.
The MIME type of the content.
This may be a primary MIME type or subtype. For example, if MIMEType is “video/” the specified view and representation objects are used for all video types. More specific subtype mappings, such as “image/gif”, takes precedence over primary type matching, such as “image/”.
After invoking this method, when MIMEType content is encountered, instances of representationClass and viewClass are created to handle and display it.
WebView.hSets the MIME types that WebKit attempts to render as HTML.
+ (void)setMIMETypesShownAsHTML:(NSArray *)MIMETypes
An array of NSString objects representing the MIME types. Typically, you create the MIMETypes array by adding additional types to the array returned by the MIMETypesShownAsHTML class method.
WebView.hReturns a URL from the specified pasteboard.
+ (NSURL *)URLFromPasteboard:(NSPasteboard *)pasteboard
The pasteboard containing a URL.
The URL from the specified pasteboard or nil if there’s no URL on pasteboard.
This method supports multiple pasteboard types including NSRULPboardType.
WebView.hReturns the title of a URL from the specified pasteboard.
+ (NSString *)URLTitleFromPasteboard:(NSPasteboard *)pasteboard
The pasteboard containing the URL.
The title of the URL on pasteboard. Returns nil if there’s no URL on pasteboard or the URL has no title.
WebView.hAn action method that applies center alignment to selected content or all content if there’s no selection.
- (void)alignCenter:(id)sender
The object that sent this message.
WebView.hAn action method that applies full justification to selected content or all content if there’s no selection.
- (void)alignJustified:(id)sender
The object that sent this message.
This method behaves similar to the alignJustified: method in NSTextView.
WebView.hAn action method that applies left justification to selected content or all content if there’s no selection.
- (void)alignLeft:(id)sender
The object that sent this message.
WebView.hAn action method that applies right justification to selected content or all content if there is no selection.
- (void)alignRight:(id)sender
The object that sent this message.
WebView.hReturns the receiver’s application name that is used in the user-agent string.
- (NSString *)applicationNameForUserAgent
The application name to use in the user-agent string. The user-agent is used by websites to identify the client browser.
WebView.hApplies the CSS typing style to the current selection.
- (void)applyStyle:(DOMCSSStyleDeclaration *)style
The style to apply to the current selection.
This method does nothing if there is no current selection or if the current selection is collapsed.
This method hides the complexities of applying styles to elements. If necessary, this method will make multiple passes over the range of the current selection to ensure that the requested style is applied to the elements in that range, and takes into account the complexities of CSS style application rules. This method also simplifies styling attributes so that the minimum number of styling directives are used to yield a given computed style.
WebView.hReturns the receiver’s back-forward list.
- (WebBackForwardList *)backForwardList
The receiver’s back-forward list.
WebView.hReturns whether the previous location can be loaded.
- (BOOL)canGoBack
YES if able to move backward; otherwise, NO.
WebView.hReturns whether the next location can be loaded.
- (BOOL)canGoForward
YES if able to move forward; otherwise, NO.
WebView.hReturns whether the text can be made larger.
- (BOOL)canMakeTextLarger
YES if able to make the text larger; otherwise, NO.
WebView.hReturns whether the text can be made smaller.
- (BOOL)canMakeTextSmaller
YES if able to make the text smaller; otherwise, NO.
WebView.hReturns whether the current text size is a multiple of 1.
- (BOOL)canMakeTextStandardSize
YES if the current text size is a multiple of 1; otherwise, NO.
WebView.hAn action method that changes the attributes of the current selection.
- (void)changeAttributes:(id)sender
The object that sent this message.
This method behaves similar to the changeAttributes: method in NSTextView.
WebView.hSets the color of the selected content.
- (void)changeColor:(id)sender
The object that sent this message.
This method is invoked by the NSColorPanel sender and behaves similar to the changeColor: method in NSTextView.
WebView.hSets the background color of the selected content.
- (void)changeDocumentBackgroundColor:(id)sender
The object that sent this message.
This method is invoked by the NSColorPanel sender and behaves similar to the changeDocumentBackgroundColor: method in NSTextView.
WebView.hAn action method that changes the font of the selection, or all content if there is no selection.
- (void)changeFont:(id)sender
The object that sent this message.
If the receiver doesn’t use the Fonts panel, this method does nothing.
WebView.hAn action method that searches for a misspelled word in the receiver.
- (void)checkSpelling:(id)sender
The object that sent this message.
This action method starts a search at the end of the selection and continues until it reaches a word suspected of being misspelled or the end of the content. If a word isn’t recognized by the spelling server, a showGuessPanel: message is sent to the receiver which opens the Guess panel and allows the user to make a correction or add the word to the local dictionary.
WebView.hCloses the web view when it’s no longer needed.
- (void)close
Closes the web view by unloading its webpage and canceling any pending load requests. A closed web view no longer responds to new requests nor sends delegate messages. If the application uses garbage collection, this method needs to be invoked before an instance is collected. It is invoked automatically if the receiver’s enclosing window or host window is closed and sending shouldCloseWithWindow to the receiver returns YES. Applications that do not use garbage collection can still use this method to stop the receiver from loading and sending delegate messages.
WebView.hReturns the computed style of an element and its pseudo element.
- (DOMCSSStyleDeclaration *)computedStyleForElement:(DOMElement *)element pseudoElement:(NSString *)pseudoElement
The element whose computed style is returned.
The pseudo element for element.
An immutable object describing the computed style of element and pseudoElement according to the Cascading Style Sheets Specification at http://www.w3.org/TR/CSS21. Returns nil if the receiver doesn’t display element.
WebView.hAction method that copies the selected content to the general pasteboard.
- (void)copy:(id)sender
The object that sent this message.
This action method copies the selected content onto the general pasteboard, in as many formats as the receiver supports. For example, a plain text object uses NSStringPboardType for plain text, and a rich text object also uses NSRTFPboardType.
WebView.hAn action method that copies font information onto the font pasteboard.
- (void)copyFont:(id)sender
The object that sent this message.
This action method copies the font information for the first character of the selection (or for the insertion point) onto the font pasteboard as NSFontPboardType.
WebView.hReturns the custom text encoding name.
- (NSString *)customTextEncodingName
The receiver’s custom text encoding name or nil if no custom text encoding name was set.
WebView.hReturns the receiver’s custom user-agent string.
- (NSString *)customUserAgent
The user-agent string to identify the client browser. The custom user-agent string is used for all URLs.
WebView.hAn action method that deletes selected content and puts it on the general pasteboard.
- (void)cut:(id)sender
The object that sent this message.
This action method deletes the selected content and places it onto the general pasteboard, in as many formats as the receiver supports. For example, a plain text object uses NSStringPboardType for plain text, and a rich text object also uses NSRTFPboardType.
WebView.hAn action method that deletes the selected content.
- (void)delete:(id)sender
The object that sent this message.
The pasteboard is unaffected by invoking this method.
WebView.hDeletes the receiver’s current selection unless it’s collapsed.
- (void)deleteSelection
No content is removed if the current selection is collapsed (a range is selected with the same nodes and offsets for the start and end) or if there is no current selection.
– replaceSelectionWithText:– replaceSelectionWithMarkupString:– replaceSelectionWithArchive:– replaceSelectionWithNode:WebView.hReturn the receiver’s download delegate.
- (id)downloadDelegate
The receiver’s download delegate that implements the WebDownload protocol.
WebView.hReturns whether the web view draws a background.
- (BOOL)drawsBackground
YES if a background is drawn; otherwise, NO.
WebView.hReturns the editable DOM object located at a given point.
- (DOMRange *)editableDOMRangeForPoint:(NSPoint)point
The location of the editable DOM object.
A single range object of the editable DOM object located at point in the receiver’s coordinates.
WebView.hReturns the receiver’s editing delegate.
- (id)editingDelegate
The receiver’s editing delegate.
WebView.hReturns a dictionary description of the element at a given point in the receiver’s coordinates.
- (NSDictionary *)elementAtPoint:(NSPoint)point
The point to represent as a dictionary.
A dictionary description of the element at point in the receiver’s coordinates.
– webView:dragDestinationActionMaskForDraggingInfo: (WebUIDelegate)– webView:dragSourceActionMaskForPoint:WebView.hReturns an estimate, as a percentage, of the amount of content that is currently loaded.
- (double)estimatedProgress
A number ranging from 0 to 1.0 and, once a load completes, 1.0 until a new load starts, at which point it resets to 0.
The value is an estimate based on the total number of bytes expected to be received for a document, including all its possible subresources. For more accurate load progress information, implement delegates conforming to the WebFrameLoadDelegate and WebResourceLoadDelegate informal protocols.
WebViewProgressEstimateChangedNotificationWebViewProgressFinishedNotificationWebViewProgressStartedNotificationWebView.hReturn the receiver’s frame load delegate.
- (id)frameLoadDelegate
A frame load delegate that conforms to the WebFrameLoadDelegate protocol.
WebView.hLoads the previous location in the back-forward list.
- (BOOL)goBack
YES if able to move backward; otherwise, NO.
WebView.hAn action method that loads the previous location in the back-forward list.
- (void)goBack:(id)sender
The object that sent this message.
This method does nothing if it is unable to move backward.
WebView.hLoads the next location in the back-forward list.
- (BOOL)goForward
YES if able to move forward; otherwise, NO.
WebView.hAn action method that loads the next location in the back-forward list.
- (void)goForward:(id)sender
The object that sent this message.
This method does nothing if it is unable to move forward.
WebView.hLoads a specific location from the back-forward list and sets it as the current item.
- (BOOL)goToBackForwardItem:(WebHistoryItem *)item
The index of the location to load. This method sets the current item in the back-forward list to item.
YES if item is in the back-forward list; otherwise, NO.
WebView.hReturns the receiver’s group name.
- (NSString *)groupName
The receiver’s group name.
WebView.hReturns the receiver’s host window.
- (NSWindow *)hostWindow
The receiver’s host window.
WebView.hInitializes the receiver with a frame rectangle, frame name, and group name.
- (id)initWithFrame:(NSRect)frameRect frameName:(NSString *)frameName groupName:(NSString *)groupName
The frame rectangle for the created view object.
The web frame’s name. This should not be one of the predefined frame names (see the WebFramefindFrameNamed: method for a description of their meaning), but a custom name or a name used in HTML source. This parameter can be nil.
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. This parameter can be nil.
An initialized view object or nil if the object couldn't be created.
This method is the designated initializer for the WebView class.
WebView.hReturns whether the web view has continuous spell-checking enabled.
- (BOOL)isContinuousSpellCheckingEnabled
YES if the object has continuous spell-checking enabled; otherwise, NO.
WebView.hReturns whether the user is allowed to edit the document.
- (BOOL)isEditable
YES if the receiver allows the user to edit the HTML document, NO if it doesn’t.
You can change the receiver’s document programmatically regardless of this setting.
WebView.hReturns whether the web view is loading content.
- (BOOL)isLoading
YES if the web view is currently loading any resources; otherwise, NO.
WebView.hReturns the main frame, the root of the web frame hierarchy for this page.
- (WebFrame *)mainFrame
The main frame.
WebView.hReturns the DOM document for the main frame.
- (DOMDocument *)mainFrameDocument
The DOM document for the main frame.
Invoking this method is equivalent to [[webView mainFrame] DOMDocument].
WebView.hReturns the site’s favicon.
- (NSImage *)mainFrameIcon
The site’s icon. Returns nil if no favicon is provided.
WebView.hReturns the HTML title of the loaded page.
- (NSString *)mainFrameTitle
The HTML title of the loaded page. Returns @"" if the loaded document is not HTML.
WebView.hReturns the URL that the main frame loads.
- (NSString *)mainFrameURL
The main frame URL string.
WebView.hReturns whether the selection is maintained when focus is lost.
- (BOOL)maintainsInactiveSelection
YES if the selection is maintained when focus is lost; otherwise, NO.
WebView.hAction method that increases the text size by one unit.
- (void)makeTextLarger:(id)sender
The object that sent this message.
WebView.hAction method that reduces the text size by one unit.
- (void)makeTextSmaller:(id)sender
The object that sent this message.
WebView.hResets the text size to a multiple of 1.
- (void)makeTextStandardSize:(id)sender
The object that sent this message.
WebView.hReturns the receiver’s CSS media property.
- (NSString *)mediaStyle
The receiver’s CSS media property. nil if no media style was set.
WebView.hMoves the drag caret that indicates the destination of a drag operation to a given point.
- (void)moveDragCaretToPoint:(NSPoint)point
The point to move the drag caret to.
WebView.hMoves the insertion point to the beginning of the current sentence.
- (void)moveToBeginningOfSentence:(id)sender
The object that sent this message.
WebView.hMoves the insertion point and extends the selection to the beginning of the current sentence.
- (void)moveToBeginningOfSentenceAndModifySelection:(id)sender
The object that sent this message.
WebView.hMoves the insertion point to the end of the current sentence.
- (void)moveToEndOfSentence:(id)sender
The object that sent this message.
WebView.hMoves the insertion point and extends the selection to the end of the current sentence.
- (void)moveToEndOfSentenceAndModifySelection:(id)sender
The object that sent this message.
WebView.hAn action method that pastes content from the pasteboard at the insertion point or over the selection.
- (void)paste:(id)sender
The object that sent this message.
WebView.hAn action method that pastes pasteboard content as plain text.
- (void)pasteAsPlainText:(id)sender
The object that sent this message.
WebView.hAn action method that pastes pasteboard content into the receiver as rich text, maintaining its attributes.
- (void)pasteAsRichText:(id)sender
The object that sent this message.
The text is inserted at the insertion point if there is one; otherwise, it replaces the selection.
WebView.hReturns an array of pasteboard types for an element.
- (NSArray *)pasteboardTypesForElement:(NSDictionary *)element
The element whose pasteboard types you want.
An array of pasteboard types for an element.
WebView.hReturns an array of pasteboard types that can be used for the current selection of the receiver.
- (NSArray *)pasteboardTypesForSelection
An array of pasteboard types that can be used for the current selection of the receiver.
WebView.hAn action method that pastes font information from the font pasteboard.
- (void)pasteFont:(id)sender
The object that sent this message.
This action method pastes font information from the font pasteboard onto the selected content or insertion point of a rich text object, or over all text of the receiver.
WebView.hAn action method that opens the Find menu and Find panel.
- (void)performFindPanelAction:(id)sender
The object that sent this message.
This method behaves similar to the performFindPanelAction: method in NSTextView.
WebView.hReturns the receiver's policy delegate.
- (id)policyDelegate
A policy delegate that conforms to the WebPolicyDelegate protocol.
WebView.hReturns the receiver’s preferences.
- (WebPreferences *)preferences
The receiver’s preferences or the standard preferences, if the preferences were not set using the setPreferences: method.
WebView.hReturns the identifier of the receiver’s preferences.
- (NSString *)preferencesIdentifier
The preferences identifier.
WebView.hAn action method that reloads the current page.
- (void)reload:(id)sender
The object that sent this message.
WebView.hAction method that performs an end-to-end revalidation using cache-validating conditionals if possible.
- (void)reloadFromOrigin:(id)sender
The object that sent this message.
– reloadFromOrigin (WebView)– reload:WebView.hRemoves the drag caret that indicates the destination of a drag operation.
- (void)removeDragCaret
WebView.hReplaces the current selection with an archive's contents.
- (void)replaceSelectionWithArchive:(WebArchive *)archive
The archive that replaces the current selection.
If the current selection is collapsed (a range is selected with the same nodes and offsets for the start and end) then no content is removed when inserting the archive, and the selection is collapsed and moved to the end of the inserted content. If no content is selected, the archive is not inserted.
– replaceSelectionWithText:– replaceSelectionWithMarkupString:– replaceSelectionWithNode:– deleteSelectionWebView.hReplaces the current selection with mixed text and markup.
- (void)replaceSelectionWithMarkupString:(NSString *)markupString
The markup string that replaces the current selection.
If the current selection is collapsed (a range is selected with the same nodes and offsets for the start and end) then no content is removed when inserting the markup, and the selection is collapsed and moved to the end of the inserted content. If no content is selected, the markup is not inserted.
See HTML Clipboard Format for a specification of the supported HTML markup.
– replaceSelectionWithText:– replaceSelectionWithNode:– replaceSelectionWithArchive:– deleteSelectionWebView.hReplaces the receiver’s current selection with the specified DOM node.
- (void)replaceSelectionWithNode:(DOMNode *)node
The node that replaces the current selection. If nil, a NOT_FOUND_ERR DOM error is thrown as an exception. Use the deleteSelection method to delete the selection.
If the current selection is collapsed (a range is selected with the same nodes and offsets for the start and end) then no content is removed when inserting the node, and the selection is collapsed and moved to the end of the inserted content. If no content is selected, the node is not inserted.
– replaceSelectionWithText:– replaceSelectionWithMarkupString:– replaceSelectionWithArchive:– deleteSelectionWebView.hReplaces the current selection with a string of text.
- (void)replaceSelectionWithText:(NSString *)text
The text that replaces the current selection.
If the current selection is collapsed (a range is selected with the same nodes and offsets for the start and end) then no content is removed when inserting the text, and the selection is collapsed and moved to the end of the inserted content. If no content is selected, the text is not inserted.
– replaceSelectionWithNode:– replaceSelectionWithMarkupString:– replaceSelectionWithArchive:– deleteSelectionWebView.hReturns the receiver’s resource load delegate.
- (id)resourceLoadDelegate
A resource load delegate that conforms to the WebResourceLoadDelegate protocol.
WebView.hSearches a document view for a string and highlights it if it is found.
- (BOOL)searchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag wrap:(BOOL)wrapFlag
The search string.
If YES the direction of the search is forward; if NO, the direction is backward.
If YES if the search is case sensitive; otherwise, it is not.
If YES if the search wraps; otherwise, it does not.
YES if the search is successful; otherwise, NO.
The search for string begins from the current selection and continues in the direction specified by forward. The search continues across all frames.
WebView.hReturns the range of the current selection.
- (DOMRange *)selectedDOMRange
The range of the current selection. nil if nothing is selected.
WebView.hReturns the frame with the active selection.
- (WebFrame *)selectedFrame
The frame that contains the first responder. If it doesn’t exist, the frame that contains a non-zero-length selection; otherwise, nil.
WebView.hReturns the current selection affinity.
- (NSSelectionAffinity)selectionAffinity
The preferred direction of selection—upward or downward—of the receiver’s current selection. For example, if text wraps across line boundaries, the value returned by this method indicates whether or not the insertion point appears after the last charactrer of the first line or before the first character of the following line.
WebView.hSelects the entire sentence around the insertion point.
- (void)selectSentence:(id)sender
The object that sent this message.
WebView.hSets the application name used in the user-agent string.
- (void)setApplicationNameForUserAgent:(NSString *)applicationName
The application name to use in the user-agent string. The user-agent is used by websites to identify the client browser.
WebView.hSets whether the web view has continuous spell-checking enabled.
- (void)setContinuousSpellCheckingEnabled:(BOOL)flag
YES if the object should have continuous spell-checking enabled; otherwise, NO.
WebView.hSets the custom text encoding name.
- (void)setCustomTextEncodingName:(NSString *)encodingName
A text encoding name. If nil, the default encoding is restored.
This method overrides the default text encoding, including any encoding that is specified in the webpage header or HTTP response. Invoking this method stops any load in progress. The default encoding is restored when the main frame changes to a new location, or if encodingName is nil.
WebView.hSets the receiver’s custom user-agent string.
- (void)setCustomUserAgent:(NSString *)userAgentString
The custom user-agent string. The user-agent string is used by websites to identify the client browser. The custom user-agent string is used for all URLs. If nil, then the receiver constructs a user-agent string that produces the best rendering results for each URL.
WebView.hSets the receiver's shared download delegate.
- (void)setDownloadDelegate:(id)delegate
The download delegate that implements the WebDownload protocol.
WebKit may create WebDownload objects automatically to handle downloads that start with a webpage or link.
WebView.hSets whether a default background is drawn when the webpage has no background set.
- (void)setDrawsBackground:(BOOL)drawsBackround
If YES, a default background is drawn; if NO, it is not.
WebView.hSets whether the receiver allows the user to edit its HTML document.
- (void)setEditable:(BOOL)flag
YES if the receiver allows the user to edit the document. NO if an element in the receiver’s document can be edited only if the CONTENTEDITABLE attribute has been set on the element or one of its parent elements.
You can change the receiver’s document programmatically regardless of this setting. By default a WebView object is not editable.
Normally, an HTML document is not editable unless the elements within the document are editable. This method provides a low-level way to make the contents of a WebView object editable without altering the document or DOM structure.
WebView.hSets the receiver’s editing delegate.
- (void)setEditingDelegate:(id)delegate
The editing delegate for the web view that conforms to the WebEditingDelegate protocol.
WebView.hSets the receiver's frame load delegate.
- (void)setFrameLoadDelegate:(id)delegate
A frame load delegate that conforms to the WebFrameLoadDelegate protocol.
WebView.hSets the receiver's group name.
- (void)setGroupName:(NSString *)groupName
An arbitrary identifier used to group related frames.
You might use this method to set the group name of a WebView object after it is loaded from a nib file.
WebView.hSets the receiver's host window.
- (void)setHostWindow:(NSWindow *)hostWindow
A host window.
This method sets the receiver’s host window to hostWindow. Your application should only use this method if a web view is going to be removed from its window temporarily, and you want the web view to continue operating (for example, you don’t want to interrupt a load in progress). Since the receiver retains hostWindow, it is your responsibility to set the host window to nil before closing the window to avoid a retain loop.
For example, you might invoke this method if you attach a web view to an NSTabView object (as in a tabbed browser implementation). The NSTabView object takes views out of the window when they are not in the active tab, so you need to invoke this method before the web view is removed from its window. If you don't invoke this method, plug-ins will stop operating when the web view is removed from its window.
WebView.hSets the URL that the main frame loads.
- (void)setMainFrameURL:(NSString *)URLString
The main frame URL string.
This method is functionally equivalent to [[webView mainFrame] loadRequest:].
WebView.hSets whether to use a back-forward list.
- (void)setMaintainsBackForwardList:(BOOL)flag
If NO, clears the back-forward list and release the page cache; otherwise, it does not.
The back-forward list maintains a page cache, so applications that do not use the goForward or goBack methods should disable it.
WebView.hSets the receiver’s CSS media property.
- (void)setMediaStyle:(NSString *)mediaStyle
The CSS media property for the receiver.
WebView.hSets the receiver's policy delegate.
- (void)setPolicyDelegate:(id)delegate
A policy delegate that conforms to the WebPolicyDelegate protocol.
WebView.hSets the receiver’s preferences.
- (void)setPreferences:(WebPreferences *)preferences
The web view’s preferences.
Typically, you do not invoke this method directly. Use the setPreferencesIdentifier: method to change the receiver’s preferences.
WebView.hSets the receiver's preferences identifier, creating a preferences object if needed.
- (void)setPreferencesIdentifier:(NSString *)anIdentifier
The unique identifier for the preferences—it is fixed to the keys used to store the receiver’s preferences in the user defaults database. WebView objects can share instances of the WebPreferences class by using the same preferences identifier.
This method sets the receiver’s preferences to the specified preferences object if it exists. Otherwise, this method creates a new WebPreferences object for the receiver initialized with anIdentifier. Use this method to change the preferences used by the receiver’s WebFrameView objects. If you do not directly set the preferences, WebFrameView objects use the preferences returned by the standardPreferences class method of WebPreferences.
WebView.hSets the receiver's resource load delegate.
- (void)setResourceLoadDelegate:(id)delegate
A resource load delegate that conforms to the WebResourceLoadDelegate protocol.
WebView.hSelects a range of nodes.
- (void)setSelectedDOMRange:(DOMRange *)range affinity:(NSSelectionAffinity)selectionAffinity
The range of nodes to select. If range is nil, the current selection is cleared. This method raises a DOMRangeExcepton if the range has been detached or refers to nodes not displayed by the receiver.
See the selectionAffinity method for information on selection affinity.
WebView.hSets whether the web view should close when its window or host window closes.
- (void)setShouldCloseWithWindow:(BOOL)close
If YES, the web view should close; otherwise, it should not.
WebView.hSets whether the web view should update even when it is not in a window that is currently visible.
- (void)setShouldUpdateWhileOffscreen:(BOOL)updateWhileOffscreen
If YES, the web view updates regardless if it is visible. If NO, it updates only if it is visible, possibly improving performance, and then updates automatically when it becomes visible. The default value is YES.
WebView.hSets whether the receiver should insert or delete spaces around selected words to preserve proper spacing and punctuation.
- (void)setSmartInsertDeleteEnabled:(BOOL)flag
If YES, the receiver performs smart insert and delete; if NO, it inserts and deletes exactly what’s selected.
WebView.hChange the font size multiplier for text displayed in web frame view objects managed by the receiver.
- (void)setTextSizeMultiplier:(float)multiplier
A fractional percentage value where 1.0 denotes 100%.
WebView.hSets the receiver’s CSS typing style.
- (void)setTypingStyle:(DOMCSSStyleDeclaration *)style
The receiver’s CSS typing style.
The typing style is reset automatically when the receiver’s selection changes.
WebView.hSets the receiver's user interface delegate.
- (void)setUIDelegate:(id)delegate
A user interface delegate that conforms to the WebUIDelegate protocol.
WebView.hReturns whether the web view should close when its window or host window closes.
- (BOOL)shouldCloseWithWindow
If YES, the web view should close; otherwise, it should not.
WebView.hReturns whether the web view should update even when it is not visible.
- (BOOL)shouldUpdateWhileOffscreen
YES if it should update even when it is not visible; otherwise, NO.
WebView.hAn action method that shows a spelling correction panel.
- (void)showGuessPanel:(id)sender
The object that sent this message.
This action method opens the Spelling panel, allowing the user to make a correction during spell checking.
WebView.hReturns whether smart-space insertion and deletion is enabled.
- (BOOL)smartInsertDeleteEnabled
YES if the receiver inserts or deletes space around selected words so as to preserve proper spacing and punctuation. NO if it inserts and deletes exactly what’s selected.
WebView.hReturns the spell-checker document tag for this document.
- (NSInteger)spellCheckerDocumentTag
The document tag for this web view. A tag identifying the receiver’s text as a document for the spell-checker server. See the NSSpellChecker and NSSpellServer class specifications for more information on how this tag is used.
The return value changed from unsigned int to a NSUInteger in Mac OS X v10.5.
spellCheckerDocumentTag (NSTextView)WebView.hAn action method that starts speaking the selected text or all text if there’s no selection.
- (void)startSpeaking:(id)sender
The object that sent this message.
Speech continues asynchronously until the end of the text or until terminated by invoking the stopSpeaking: method. This method behaves similar to the startSpeaking: method in NSTextView.
WebView.hAn action method that stops the loading of any web frame content managed by the receiver.
- (void)stopLoading:(id)sender
The object that sent this message.
Stops any content in the process of being loaded by the main frame or any of its children frames. Does nothing if no content is being loaded.
WebView.hAn action method that stops speaking that is in progress.
- (void)stopSpeaking:(id)sender
The object that sent this message.
This action method stops speech that was previously started with startSpeaking:. This method behaves similar to the stopSpeaking: method in NSTextView.
WebView.hReturns the result of running a script.
- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script
The script to run.
The result of running a JavaScript specified by script, or an empty string if the script failed.
WebView.hReturns the CSS style declaration for the specified text.
- (DOMCSSStyleDeclaration *)styleDeclarationWithText:(NSString *)text
The text whose style declaration is returned.
The style declaration for text.
WebView.hReturns whether the document view supports different text encodings.
- (BOOL)supportsTextEncoding
YES if the receiver’s document view can support different text encodings; otherwise, NO.
WebView.hSets the receiver’s current location by obtaining a URL string from the sender.
- (void)takeStringURLFrom:(id)sender
The object that sent this message.
This method sets the receiver’s current location to the value obtained by sending a stringValue message to sender, then starts loading the URL returned by sender.
– loadRequest: (WebFrame)WebView.hReturns the font size multiplier for text displayed in web frame view objects managed by the receiver.
- (float)textSizeMultiplier
The font size multiplier, a fractional percentage value where 1.0 denotes 100%.
WebView.hToggles whether continuous spell checking is available.
- (void)toggleContinuousSpellChecking:(id)sender
The object that sent this message.
WebView.hToggles whether spaces around selected words are inserted or deleted to preserve proper spacing and punctuation.
- (void)toggleSmartInsertDelete:(id)sender
The object that sent this message.
WebView.hReturns the receiver’s CSS typing style.
- (DOMCSSStyleDeclaration *)typingStyle
The receiver’s CSS typing style.
WebView.hReturns the receiver's user interface delegate.
- (id)UIDelegate
A user interface delegate that conforms to the WebUIDelegate protocol.
WebView.hReturns the receiver’s undo manager.
- (NSUndoManager *)undoManager
The receiver’s undo manager.
WebView.hReturns the appropriate user-agent string for a given URL.
- (NSString *)userAgentForURL:(NSURL *)URL
The URL that you need the user-agent string for.
The user-agent string for a given URL. The user-agent string is used by websites to identify the client browser.
WebView.hReturns the receiver’s window object from the scripting environment.
- (WebScriptObject *)windowScriptObject
The receiver’s window object.
– objectForWebScript (WebPlugIn) (WebFrameLoadDelegate)– webView:windowScriptObjectAvailable:WebView.hWrites an element to the pasteboard using a list of types.
- (void)writeElement:(NSDictionary *)element withPasteboardTypes:(NSArray *)types toPasteboard:(NSPasteboard *)pasteboard
The element to write to the pasteboard.
The pasteboard types to use for the element.
The pasteboard to use for writing.
WebView.hWrites the receiver’s current selection to a pasteboard using a list of types.
- (void)writeSelectionWithPasteboardTypes:(NSArray *)types toPasteboard:(NSPasteboard *)pasteboard
The pasteboard types to use for the selection.
The pasteboard to use for writing.
WebView.hPredefined keys used to access an element dictionary.
extern NSString *WebElementDOMNodeKey; extern NSString *WebElementFrameKey; extern NSString *WebElementImageAltStringKey; extern NSString *WebElementImageKey; extern NSString *WebElementImageRectKey; extern NSString *WebElementImageURLKey; extern NSString *WebElementIsSelectedKey; extern NSString *WebElementLinkURLKey; extern NSString *WebElementLinkTargetFrameKey; extern NSString *WebElementLinkTitleKey; extern NSString *WebElementLinkLabelKey;
WebElementDOMNodeKeyThe DOMNode for this element.
Available in Mac OS X v10.3 and later.
Declared in WebView.h.
WebElementFrameKeyThe WebFrame object associated with this element.
Available in Mac OS X v10.2 and later.
Declared in WebView.h.
WebElementImageAltStringKeyAn NSString of the ALT attribute of an image element.
Available in Mac OS X v10.2 and later.
Declared in WebView.h.
WebElementImageKeyAn NSImage representing an image element.
Available in Mac OS X v10.2 and later.
Declared in WebView.h.
WebElementImageRectKeyAn NSValue containing an NSRect, the size of an image element.
Available in Mac OS X v10.2 and later.
Declared in WebView.h.
WebElementImageURLKeyAn NSURL containing the location of an image element.
Available in Mac OS X v10.2 and later.
Declared in WebView.h.
WebElementIsSelectedKeyAn NSNumber used as a BOOL value to indicate whether a text element is selected or not. Zero value indicates false, true otherwise.
Available in Mac OS X v10.2 and later.
Declared in WebView.h.
WebElementLinkURLKeyAn NSURL containing the location of a link if the element is within an anchor.
Available in Mac OS X v10.2 and later.
Declared in WebView.h.
WebElementLinkTargetFrameKeyThe WebFrame object associated with the target of the anchor.
Available in Mac OS X v10.2 and later.
Declared in WebView.h.
WebElementLinkTitleKeyAn NSString containing the title of an anchor.
Available in Mac OS X v10.2 and later.
Declared in WebView.h.
WebElementLinkLabelKeyAn NSString containing the text within an anchor.
Available in Mac OS X v10.2 and later.
Declared in WebView.h.
These constants represent predefined keys used to access an element dictionary. An element dictionary is an NSDictionary representation of an HTML element, as in a clicked or selected element. Some methods in the WebPolicyDelegate informal protocol have an element dictionary argument. The descriptions below describe the dictionary value for the key.
Posted when a web view begins any operation that changes its contents in response to user editing. The notification object is the WebView object that the user is editing. This notification does not contain a userInfo dictionary.
WebView.hPosted when a web view performs any operation that changes its contents in response to user editing. The notification object is the WebView object that the user is editing. This notification does not contain a userInfo dictionary.
WebView.hPosted when a web view changes its typing selection. The notification object is the WebView that changed its typing selection. This notification does not contain a userInfo dictionary.
WebView.hPosted when a web view changes its typing style. The notification object is the WebView that changed its typing style. This notification does not contain a userInfo dictionary.
WebView.hPosted when a web view ends any operation that changes its contents in response to user editing. The notification object is the WebView that the user is editing. This notification does not contain a userInfo dictionary.
WebView.hPosted by a WebView object when the estimated progress value of a load changes. This notification may be posted zero or more times after a WebViewProgressStartedNotification notification is posted. The notification object is the WebView for which the progress value has changed. This notification does not contain a userInfo dictionary.
WebView.hPosted by a WebView object when the load has finished. The notification object is the WebView that finished loading. This notification does not contain a userInfo dictionary.
WebView.hPosted by a WebView object when a load begins, including a load that is initiated in a subframe. The notification object is the WebView that began loading. This notification does not contain a userInfo dictionary.
WebView.hLast updated: 2009-05-21