原文地址:http://developer.apple.com/mac/library/documentation/cocoa/Reference/WebKit/Classes/WebView_Class/Reference/Reference.html ;
继承 NSView : NSResponder : NSObject的
符合 NSAnimatablePropertyContainer(NSView)
NSCoding(NSResponder)
NSObject的(NSObject的)
框架 /系统/资源库/框架/ WebKit.framework
可用性 在Mac OS X v10.2时可使用Safari 1.0和更高版本。
可用在Mac OS X v10.2.7和更高版本。
同伴指导 WebKit的Objective - C的编程指南
申报的 WebView.h
相关的示例代码 CallJS
iChatTheater
新闻阅读器
SourceView
SpecialPictureProtocol
概观
WebView是WebKit的管理框架中核心视图类, 管理WebFrame和WebFrameView类的相互作用。要在应用程序中嵌入网页内容,只需创建一个WebView对象,将其附加到一个窗口,并传送loadRequest:信息的主框架。
后台, 一个框架元素中包含WebFrame对象封装中包含的内容。WebFrame对象的层次结构在主框架模拟一个完整的网页。每个WebFrame对象中都有一个WebFrameView对象,用于显示框架内容。因此,WebFrameView对象的并行层次用于渲染整个页面。WebView对象也是层次结构的父类视图。 不需要直接创建WebFrame和WebFrameView对象。 这些对象会在页面加载,编程或用户点击一个链接时自动创建。
您可以执行WebView delegates 处理视位图来自定义嵌入网页内容。 如果出现错误,WebView对象有多个delegates,因为网页加载进程是异步的和复杂的。 所有WebView delegates使用非正式协议,所以您想改变已经提供的默认实现,只需要实现delegates and methods 来定义性能。
例如,您可能要执行框架加载和资源加载的delegates,以监察加载进度和加载状态信息显示。 应用程序使用多个窗口可能需要实现用户界面delegate。 更多细节见其他协议: WebFrameLoadDelegate协议参考 , WebPolicyDelegate协议参考 , WebResourceLoadDelegate协议参考 ,并WebUIDelegate协议参考 。
另一种监测控制加载进度的方法是观察WebViewProgressEstimateChangedNotification , WebViewProgressFinishedNotification和WebViewProgressStartedNotification。 例如,你可以观察这些通知在应用程序中实现一个简单的进度指示器。 更新进度指示器通过调用estimatedProgress方法来获得目前大致加载的内容数量。
WebView对象是为了支持网页浏览器大多数功能,除了不能实现的特殊用户界面。 负责实现用户界面对象如:状态栏,工具栏,按钮和文本字段。 例如,一个WebView对象管理back-forward list通过default和goBack:和goForward:的操作方法。 你的责任就是,创建按钮然后发送这些动作消息。 请注意,在维护back-forward list和页面缓存时有一些开销,如果你的应用程序不使用它应该禁用。
使用WebPreferences对象来封装的WebView对象的参数,如字体,文本编码和图像设置。 您可以为个别WebView对象或指定共享WebPreferences对象通过使用setPreferencesIdentifier: method来修改参数。 使用setAutosaves: WebPreferences method 来说明参数是否应自动保存到用户的默认数据库。
您还可以扩展Webkit通过实现自己的文件浏览和特定的MIME类型的代表性类。 使用registerViewClass:representationClass:forMIMEType:类方法来注册带有WebView对象自定义类。
任务
注册文档视图及表示法
+ registerURLSchemeAsLocal:
+ registerViewClass:representationClass:forMIMEType:
初始化视图
– initWithFrame:frameName:groupName:
关闭视图
– close
– shouldCloseWithWindow
– setShouldCloseWithWindow:
获取主框架
– mainFrame
加载内容
– stopLoading:
– takeStringURLFrom:
– reload:
– reloadFromOrigin:
– estimatedProgress
画图
– drawsBackground
– setDrawsBackground:
– setShouldUpdateWhileOffscreen:
– shouldUpdateWhileOffscreen
向前与向后移动
– setMaintainsBackForwardList:
– backForwardList
– canGoBack
– goBack
– goBack:
– canGoForward
– goForward
– goForward:
– goToBackForwardItem:
更改文字大小
– canMakeTextLarger
– makeTextLarger:
– canMakeTextSmaller
– makeTextSmaller:
获取和设置代表
– downloadDelegate
– setDownloadDelegate:
– frameLoadDelegate
– setFrameLoadDelegate:
– policyDelegate
– setPolicyDelegate:
– resourceLoadDelegate
– setResourceLoadDelegate:
– UIDelegate
– setUIDelegate:
获取和设置窗口
– hostWindow
– setHostWindow:
获取和设置参数
– preferences
– setPreferences:
– preferencesIdentifier
– setPreferencesIdentifier:
获取和设置框架内容
– isLoading
– selectedFrame
– setMainFrameURL:
– mainFrameURL
– mainFrameTitle
– mainFrameIcon
– mainFrameDocument
获取和设置内容信息
+ canShowMIMEType:
+ MIMETypesShownAsHTML
+ setMIMETypesShownAsHTML:
+ canShowMIMETypeAsHTML:
– supportsTextEncoding
– customTextEncodingName
– setCustomTextEncodingName:
– textSizeMultiplier
– setTextSizeMultiplier:
搜索文档
– searchFor:direction:caseSensitive:wrap:
获取和设置组名称
– groupName
– setGroupName:
获取和设置用户代理字符串
– userAgentForURL:
– applicationNameForUserAgent
– setApplicationNameForUserAgent:
– customUserAgent
– setCustomUserAgent:
处理JavaScript
– stringByEvaluatingJavaScriptFromString:
使用Pasteboard
+ URLFromPasteboard:
+ URLTitleFromPasteboard:
– pasteboardTypesForElement:
– pasteboardTypesForSelection
– writeElement:withPasteboardTypes:toPasteboard:
– writeSelectionWithPasteboardTypes:toPasteboard:
拖动
– elementAtPoint:
– moveDragCaretToPoint:
– removeDragCaret
剪切,复制和粘贴操作方法
– copy:
– copyFont:
– cut:
– delete:
– paste:
– pasteFont:
– pasteAsPlainText:
– pasteAsRichText:
内容对齐操作方法
– alignCenter:
– alignJustified:
– alignLeft:
– alignRight:
编辑时改变字体,颜色和其他属性编辑
– changeFont:
– changeAttributes:
– changeDocumentBackgroundColor:
– changeColor:
拼写检查
– checkSpelling:
– showGuessPanel:
查找面板
– performFindPanelAction:
控制可说性文本
– startSpeaking:
– stopSpeaking:
获取和设置文件编辑属性
– 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
文件中选择内容
– selectedDOMRange
– setSelectedDOMRange:affinity:
– selectionAffinity
获取和设置CSS属性
– computedStyleForElement:pseudoElement:
– mediaStyle
– setMediaStyle:
– typingStyle
– setTypingStyle:
– styleDeclarationWithText:
– applyStyle:
使用WebScript
– windowScriptObject
类方法
canShowMIMEType:
Returns whether the receiver can display content of a given MIME type.
+ (BOOL)canShowMIMEType:(NSString *)MIMEType
Parameters
MIMEType
The MIME type of the content.
Return Value
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.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
Declared In
WebView.h
canShowMIMETypeAsHTML:
Returns whether the receiver interprets a MIME type as HTML.
+ (BOOL)canShowMIMETypeAsHTML:(NSString *)MIMEType
Parameters
MIMEType
The MIME type of the content.
Return Value
YES if the receiver interprets MIMEType as HTML; otherwise, NO.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
Declared In
WebView.h
MIMETypesShownAsHTML
Returns a list of MIME types that WebKit renders as HTML.
+ (NSArray *)MIMETypesShownAsHTML
Return Value
An array containing NSString objects that represent the MIME types WebKit attempts to render as HTML.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
+ setMIMETypesShownAsHTML:
Declared In
WebView.h
registerURLSchemeAsLocal:
Adds the specified URL scheme to the list of local schemes.
+ (void)registerURLSchemeAsLocal:(NSString *)scheme
Parameters
scheme
The scheme to add to the list.
Discussion
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.
Availability
Available in Mac OS X v10.4.11 and later.
Declared In
WebView.h
registerViewClass:representationClass:forMIMEType:
Specifies the view and representation objects to be used for specific MIME types.
+ (void)registerViewClass:(Class)viewClass representationClass:(Class)representationClass forMIMEType:(NSString *)MIMEType
Parameters
viewClass
A class conforming to the WebDocumentView protocol that displays the specified MIME types.
representationClass
The class conforming to WebDocumentRepresentation protocol that represents the specified MIME types.
MIMEType
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/”.
Discussion
After invoking this method, when MIMEType content is encountered, instances of representationClass and viewClass are created to handle and display it.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
Declared In
WebView.h
setMIMETypesShownAsHTML:
Sets the MIME types that WebKit attempts to render as HTML.
+ (void)setMIMETypesShownAsHTML:(NSArray *)MIMETypes
Parameters
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.
Availability
Available in Mac OS X v10.3.9 and later.
Declared In
WebView.h
URLFromPasteboard:
Returns a URL from the specified pasteboard.
+ (NSURL *)URLFromPasteboard:(NSPasteboard *)pasteboard
Parameters
pasteboard
The pasteboard containing a URL.
Return Value
The URL from the specified pasteboard or nil if there’s no URL on pasteboard.
Discussion
This method supports multiple pasteboard types including NSRULPboardType.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
+ URLTitleFromPasteboard:
Declared In
WebView.h
URLTitleFromPasteboard:
Returns the title of a URL from the specified pasteboard.
+ (NSString *)URLTitleFromPasteboard:(NSPasteboard *)pasteboard
Parameters
pasteboard
The pasteboard containing the URL.
Return Value
The title of the URL on pasteboard. Returns nil if there’s no URL on pasteboard or the URL has no title.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
+ URLFromPasteboard:
Declared In
WebView.h
Instance Methods
alignCenter:
An action method that applies center alignment to selected content or all content if there’s no selection.
- (void)alignCenter:(id)sender
Parameters
sender
The object that sent this message.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– alignJustified:
– alignLeft:
– alignRight:
Declared In
WebView.h
alignJustified:
An action method that applies full justification to selected content or all content if there’s no selection.
- (void)alignJustified:(id)sender
Parameters
sender
The object that sent this message.
Discussion
This method behaves similar to the alignJustified: method in NSTextView.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– alignJustified:
– alignLeft:
– alignRight:
Declared In
WebView.h
alignLeft:
An action method that applies left justification to selected content or all content if there’s no selection.
- (void)alignLeft:(id)sender
Parameters
sender
The object that sent this message.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– alignJustified:
– alignCenter:
– alignRight:
Declared In
WebView.h
alignRight:
An action method that applies right justification to selected content or all content if there is no selection.
- (void)alignRight:(id)sender
Parameters
sender
The object that sent this message.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– alignJustified:
– alignLeft:
– alignCenter:
Declared In
WebView.h
applicationNameForUserAgent
Returns the receiver’s application name that is used in the user-agent string.
- (NSString *)applicationNameForUserAgent
Return Value
The application name to use in the user-agent string. The user-agent is used by websites to identify the client browser.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– setApplicationNameForUserAgent:
– setCustomUserAgent:
– customUserAgent
Declared In
WebView.h
applyStyle:
Applies the CSS typing style to the current selection.
- (void)applyStyle:(DOMCSSStyleDeclaration *)style
Parameters
style
The style to apply to the current selection.
Discussion
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.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– setTypingStyle:
– typingStyle
– computedStyleForElement:pseudoElement:
Declared In
WebView.h
backForwardList
Returns the receiver’s back-forward list.
- (WebBackForwardList *)backForwardList
Return Value
The receiver’s back-forward list.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– goBack
– goForward
– goToBackForwardItem:
Declared In
WebView.h
canGoBack
Returns whether the previous location can be loaded.
- (BOOL)canGoBack
Return Value
YES if able to move backward; otherwise, NO.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– goBack:
– canGoForward
– goForward:
Declared In
WebView.h
canGoForward
Returns whether the next location can be loaded.
- (BOOL)canGoForward
Return Value
YES if able to move forward; otherwise, NO.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– goForward:
– canGoBack
– goBack:
Declared In
WebView.h
canMakeTextLarger
Returns whether the text can be made larger.
- (BOOL)canMakeTextLarger
Return Value
YES if able to make the text larger; otherwise, NO.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– makeTextLarger:
– makeTextSmaller:
– canMakeTextSmaller
Declared In
WebView.h
canMakeTextSmaller
Returns whether the text can be made smaller.
- (BOOL)canMakeTextSmaller
Return Value
YES if able to make the text smaller; otherwise, NO.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– makeTextSmaller:
– canMakeTextLarger
– makeTextLarger:
Declared In
WebView.h
canMakeTextStandardSize
Returns whether the current text size is a multiple of 1.
- (BOOL)canMakeTextStandardSize
Return Value
YES if the current text size is a multiple of 1; otherwise, NO.
Availability
Available in Mac OS X v10.4.11 and later.
Declared In
WebView.h
changeAttributes:
An action method that changes the attributes of the current selection.
- (void)changeAttributes:(id)sender
Parameters
sender
The object that sent this message.
Discussion
This method behaves similar to the changeAttributes: method in NSTextView.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– changeFont:
Declared In
WebView.h
changeColor:
Sets the color of the selected content.
- (void)changeColor:(id)sender
Parameters
sender
The object that sent this message.
Discussion
This method is invoked by the NSColorPanel sender and behaves similar to the changeColor: method in NSTextView.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– changeDocumentBackgroundColor:
Declared In
WebView.h
changeDocumentBackgroundColor:
Sets the background color of the selected content.
- (void)changeDocumentBackgroundColor:(id)sender
Parameters
sender
The object that sent this message.
Discussion
This method is invoked by the NSColorPanel sender and behaves similar to the changeDocumentBackgroundColor: method in NSTextView.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– changeColor:
Declared In
WebView.h
changeFont:
An action method that changes the font of the selection, or all content if there is no selection.
- (void)changeFont:(id)sender
Parameters
sender
The object that sent this message.
Discussion
If the receiver doesn’t use the Fonts panel, this method does nothing.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– changeAttributes:
Declared In
WebView.h
checkSpelling:
An action method that searches for a misspelled word in the receiver.
- (void)checkSpelling:(id)sender
Parameters
sender
The object that sent this message.
Discussion
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.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– showGuessPanel:
Declared In
WebView.h
close
Closes the web view when it’s no longer needed.
- (void)close
Discussion
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.
Availability
Available in Mac OS X v10.4.11 and later.
Declared In
WebView.h
computedStyleForElement:pseudoElement:
Returns the computed style of an element and its pseudo element.
- (DOMCSSStyleDeclaration *)computedStyleForElement:(DOMElement *)element pseudoElement:(NSString *)pseudoElement
Parameters
element
The element whose computed style is returned.
pseudoElement
The pseudo element for element.
Return Value
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.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– typingStyle
– setTypingStyle:
– applyStyle:
Declared In
WebView.h
copy:
Action method that copies the selected content to the general pasteboard.
- (void)copy:(id)sender
Parameters
sender
The object that sent this message.
Discussion
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.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– cut:
– paste:
Declared In
WebView.h
copyFont:
An action method that copies font information onto the font pasteboard.
- (void)copyFont:(id)sender
Parameters
sender
The object that sent this message.
Discussion
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.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– pasteFont:
Declared In
WebView.h
customTextEncodingName
Returns the custom text encoding name.
- (NSString *)customTextEncodingName
Return Value
The receiver’s custom text encoding name or nil if no custom text encoding name was set.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– setCustomTextEncodingName:
Declared In
WebView.h
customUserAgent
Returns the receiver’s custom user-agent string.
- (NSString *)customUserAgent
Return Value
The user-agent string to identify the client browser. The custom user-agent string is used for all URLs.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– setApplicationNameForUserAgent:
– applicationNameForUserAgent
– customUserAgent
Declared In
WebView.h
cut:
An action method that deletes selected content and puts it on the general pasteboard.
- (void)cut:(id)sender
Parameters
sender
The object that sent this message.
Discussion
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.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– copy:
– paste:
Declared In
WebView.h
delete:
An action method that deletes the selected content.
- (void)delete:(id)sender
Parameters
sender
The object that sent this message.
Discussion
The pasteboard is unaffected by invoking this method.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– cut:
Declared In
WebView.h
deleteSelection
Deletes the receiver’s current selection unless it’s collapsed.
- (void)deleteSelection
Discussion
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.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– replaceSelectionWithText:
– replaceSelectionWithMarkupString:
– replaceSelectionWithArchive:
– replaceSelectionWithNode:
Declared In
WebView.h
downloadDelegate
Return the receiver’s download delegate.
- (id)downloadDelegate
Return Value
The receiver’s download delegate that implements the WebDownload protocol.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– setDownloadDelegate:
Declared In
WebView.h
drawsBackground
Returns whether the web view draws a background.
- (BOOL)drawsBackground
Return Value
YES if a background is drawn; otherwise, NO.
Availability
Available in Mac OS X v10.4.11 and later.
Declared In
WebView.h
editableDOMRangeForPoint:
Returns the editable DOM object located at a given point.
- (DOMRange *)editableDOMRangeForPoint:(NSPoint)point
Parameters
point
The location of the editable DOM object.
Return Value
A single range object of the editable DOM object located at point in the receiver’s coordinates.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– selectedDOMRange
– setSelectedDOMRange:affinity:
Declared In
WebView.h
editingDelegate
Returns the receiver’s editing delegate.
- (id)editingDelegate
Return Value
The receiver’s editing delegate.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– setEditingDelegate:
Declared In
WebView.h
elementAtPoint:
Returns a dictionary description of the element at a given point in the receiver’s coordinates.
- (NSDictionary *)elementAtPoint:(NSPoint)point
Parameters
point
The point to represent as a dictionary.
Return Value
A dictionary description of the element at point in the receiver’s coordinates.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– webView:dragDestinationActionMaskForDraggingInfo: (WebUIDelegate)
– webView:dragSourceActionMaskForPoint:
Declared In
WebView.h
estimatedProgress
Returns an estimate, as a percentage, of the amount of content that is currently loaded.
- (double)estimatedProgress
Return Value
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.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
WebViewProgressEstimateChangedNotification
WebViewProgressFinishedNotification
WebViewProgressStartedNotification
Declared In
WebView.h
frameLoadDelegate
Return the receiver’s frame load delegate.
- (id)frameLoadDelegate
Return Value
A frame load delegate that conforms to the WebFrameLoadDelegate protocol.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– setFrameLoadDelegate:
Declared In
WebView.h
goBack
Loads the previous location in the back-forward list.
- (BOOL)goBack
Return Value
YES if able to move backward; otherwise, NO.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– backForwardList
– goForward
– goToBackForwardItem:
Declared In
WebView.h
goBack:
An action method that loads the previous location in the back-forward list.
- (void)goBack:(id)sender
Parameters
sender
The object that sent this message.
Discussion
This method does nothing if it is unable to move backward.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– goForward:
Declared In
WebView.h
goForward
Loads the next location in the back-forward list.
- (BOOL)goForward
Return Value
YES if able to move forward; otherwise, NO.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– goToBackForwardItem:
– goBack
Declared In
WebView.h
goForward:
An action method that loads the next location in the back-forward list.
- (void)goForward:(id)sender
Parameters
sender
The object that sent this message.
Discussion
This method does nothing if it is unable to move forward.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– goBack:
Declared In
WebView.h
goToBackForwardItem:
Loads a specific location from the back-forward list and sets it as the current item.
- (BOOL)goToBackForwardItem:(WebHistoryItem *)item
Parameters
item
The index of the location to load. This method sets the current item in the back-forward list to item.
Return Value
YES if item is in the back-forward list; otherwise, NO.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– goForward
– goBack
– backForwardList
Declared In
WebView.h
groupName
Returns the receiver’s group name.
- (NSString *)groupName
Return Value
The receiver’s group name.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– setGroupName:
Declared In
WebView.h
hostWindow
Returns the receiver’s host window.
- (NSWindow *)hostWindow
Return Value
The receiver’s host window.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– setHostWindow:
Declared In
WebView.h
initWithFrame:frameName:groupName:
Initializes the receiver with a frame rectangle, frame name, and group name.
- (id)initWithFrame:(NSRect)frameRect frameName:(NSString *)frameName groupName:(NSString *)groupName
Parameters
frameRect
The frame rectangle for the created view object.
frameName
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.
groupName
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.
Return Value
An initialized view object or nil if the object couldn't be created.
Discussion
This method is the designated initializer for the WebView class.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
Declared In
WebView.h
isContinuousSpellCheckingEnabled
Returns whether the web view has continuous spell-checking enabled.
- (BOOL)isContinuousSpellCheckingEnabled
Return Value
YES if the object has continuous spell-checking enabled; otherwise, NO.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– setContinuousSpellCheckingEnabled:
Declared In
WebView.h
isEditable
Returns whether the user is allowed to edit the document.
- (BOOL)isEditable
Return Value
YES if the receiver allows the user to edit the HTML document, NO if it doesn’t.
Discussion
You can change the receiver’s document programmatically regardless of this setting.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– setEditable:
Declared In
WebView.h
isLoading
Returns whether the web view is loading content.
- (BOOL)isLoading
Return Value
YES if the web view is currently loading any resources; otherwise, NO.
Availability
Available in Mac OS X v10.4.11 and later.
Declared In
WebView.h
mainFrame
Returns the main frame, the root of the web frame hierarchy for this page.
- (WebFrame *)mainFrame
Return Value
The main frame.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
Related Sample Code
NewsReader
Declared In
WebView.h
mainFrameDocument
Returns the DOM document for the main frame.
- (DOMDocument *)mainFrameDocument
Return Value
The DOM document for the main frame.
Discussion
Invoking this method is equivalent to [[webView mainFrame] DOMDocument].
Availability
Available in Mac OS X v10.4.11 and later.
Declared In
WebView.h
mainFrameIcon
Returns the site’s favicon.
- (NSImage *)mainFrameIcon
Return Value
The site’s icon. Returns nil if no favicon is provided.
Availability
Available in Mac OS X v10.4.11 and later.
Declared In
WebView.h
mainFrameTitle
Returns the HTML title of the loaded page.
- (NSString *)mainFrameTitle
Return Value
The HTML title of the loaded page. Returns @"" if the loaded document is not HTML.
Availability
Available in Mac OS X v10.4.11 and later.
Declared In
WebView.h
mainFrameURL
Returns the URL that the main frame loads.
- (NSString *)mainFrameURL
Return Value
The main frame URL string.
Discussion
This method is functionally equivalent to invoking [[[[[webView mainFrame] provisionalDataSource] request] URL] absoluteString].
Availability
Available in Mac OS X v10.4.11 and later.
Declared In
WebView.h
maintainsInactiveSelection
Returns whether the selection is maintained when focus is lost.
- (BOOL)maintainsInactiveSelection
Return Value
YES if the selection is maintained when focus is lost; otherwise, NO.
Availability
Available in Mac OS X v10.4.11 and later.
Declared In
WebView.h
makeTextLarger:
Action method that increases the text size by one unit.
- (void)makeTextLarger:(id)sender
Parameters
sender
The object that sent this message.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– canMakeTextLarger
– canMakeTextSmaller
– makeTextSmaller:
Declared In
WebView.h
makeTextSmaller:
Action method that reduces the text size by one unit.
- (void)makeTextSmaller:(id)sender
Parameters
sender
The object that sent this message.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– canMakeTextSmaller
– canMakeTextLarger
– makeTextLarger:
Declared In
WebView.h
makeTextStandardSize:
Resets the text size to a multiple of 1.
- (void)makeTextStandardSize:(id)sender
Parameters
sender
The object that sent this message.
Availability
Available in Mac OS X v10.4.11 and later.
Declared In
WebView.h
mediaStyle
Returns the receiver’s CSS media property.
- (NSString *)mediaStyle
Return Value
The receiver’s CSS media property. nil if no media style was set.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– setMediaStyle:
Declared In
WebView.h
moveDragCaretToPoint:
Moves the drag caret that indicates the destination of a drag operation to a given point.
- (void)moveDragCaretToPoint:(NSPoint)point
Parameters
point
The point to move the drag caret to.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– removeDragCaret
Declared In
WebView.h
moveToBeginningOfSentence:
Moves the insertion point to the beginning of the current sentence.
- (void)moveToBeginningOfSentence:(id)sender
Parameters
sender
The object that sent this message.
Availability
Available in Mac OS X v10.4.11 and later.
Declared In
WebView.h
moveToBeginningOfSentenceAndModifySelection:
Moves the insertion point and extends the selection to the beginning of the current sentence.
- (void)moveToBeginningOfSentenceAndModifySelection:(id)sender
Parameters
sender
The object that sent this message.
Availability
Available in Mac OS X v10.4.11 and later.
Declared In
WebView.h
moveToEndOfSentence:
Moves the insertion point to the end of the current sentence.
- (void)moveToEndOfSentence:(id)sender
Parameters
sender
The object that sent this message.
Availability
Available in Mac OS X v10.4.11 and later.
Declared In
WebView.h
moveToEndOfSentenceAndModifySelection:
Moves the insertion point and extends the selection to the end of the current sentence.
- (void)moveToEndOfSentenceAndModifySelection:(id)sender
Parameters
sender
The object that sent this message.
Availability
Available in Mac OS X v10.4.11 and later.
Declared In
WebView.h
paste:
An action method that pastes content from the pasteboard at the insertion point or over the selection.
- (void)paste:(id)sender
Parameters
sender
The object that sent this message.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– cut:
– copy:
Declared In
WebView.h
pasteAsPlainText:
An action method that pastes pasteboard content as plain text.
- (void)pasteAsPlainText:(id)sender
Parameters
sender
The object that sent this message.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– pasteAsRichText:
Declared In
WebView.h
pasteAsRichText:
An action method that pastes pasteboard content into the receiver as rich text, maintaining its attributes.
- (void)pasteAsRichText:(id)sender
Parameters
sender
The object that sent this message.
Discussion
The text is inserted at the insertion point if there is one; otherwise, it replaces the selection.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– pasteAsPlainText:
Declared In
WebView.h
pasteboardTypesForElement:
Returns an array of pasteboard types for an element.
- (NSArray *)pasteboardTypesForElement:(NSDictionary *)element
Parameters
element
The element whose pasteboard types you want.
Return Value
An array of pasteboard types for an element.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– pasteboardTypesForSelection
+ URLFromPasteboard:
+ URLTitleFromPasteboard:
Declared In
WebView.h
pasteboardTypesForSelection
Returns an array of pasteboard types that can be used for the current selection of the receiver.
- (NSArray *)pasteboardTypesForSelection
Return Value
An array of pasteboard types that can be used for the current selection of the receiver.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– pasteboardTypesForElement:
+ URLFromPasteboard:
+ URLTitleFromPasteboard:
Declared In
WebView.h
pasteFont:
An action method that pastes font information from the font pasteboard.
- (void)pasteFont:(id)sender
Parameters
sender
The object that sent this message.
Discussion
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.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– copyFont:
Declared In
WebView.h
performFindPanelAction:
An action method that opens the Find menu and Find panel.
- (void)performFindPanelAction:(id)sender
Parameters
sender
The object that sent this message.
Discussion
This method behaves similar to the performFindPanelAction: method in NSTextView.
Availability
Available in Mac OS X v10.3.9 and later.
Declared In
WebView.h
policyDelegate
Returns the receiver's policy delegate.
- (id)policyDelegate
Return Value
A policy delegate that conforms to the WebPolicyDelegate protocol.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– setPolicyDelegate:
Declared In
WebView.h
preferences
Returns the receiver’s preferences.
- (WebPreferences *)preferences
Return Value
The receiver’s preferences or the standard preferences, if the preferences were not set using the setPreferences: method.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– setPreferences:
+ standardPreferences
Declared In
WebView.h
preferencesIdentifier
Returns the identifier of the receiver’s preferences.
- (NSString *)preferencesIdentifier
Return Value
The preferences identifier.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– setPreferencesIdentifier:
Declared In
WebView.h
reload:
An action method that reloads the current page.
- (void)reload:(id)sender
Parameters
sender
The object that sent this message.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– setResourceLoadDelegate:
Declared In
WebView.h
reloadFromOrigin:
Action method that performs an end-to-end revalidation using cache-validating conditionals if possible.
- (void)reloadFromOrigin:(id)sender
Parameters
sender
The object that sent this message.
Availability
Available in Mac OS X v10.6 and later.
See Also
– reloadFromOrigin (WebView)
– reload:
Declared In
WebView.h
removeDragCaret
Removes the drag caret that indicates the destination of a drag operation.
- (void)removeDragCaret
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– moveDragCaretToPoint:
Declared In
WebView.h
replaceSelectionWithArchive:
Replaces the current selection with an archive's contents.
- (void)replaceSelectionWithArchive:(WebArchive *)archive
Parameters
archive
The archive that replaces the current selection.
Discussion
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.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– replaceSelectionWithText:
– replaceSelectionWithMarkupString:
– replaceSelectionWithNode:
– deleteSelection
Declared In
WebView.h
replaceSelectionWithMarkupString:
Replaces the current selection with mixed text and markup.
- (void)replaceSelectionWithMarkupString:(NSString *)markupString
Parameters
markupString
The markup string that replaces the current selection.
Discussion
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.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– replaceSelectionWithText:
– replaceSelectionWithNode:
– replaceSelectionWithArchive:
– deleteSelection
Declared In
WebView.h
replaceSelectionWithNode:
Replaces the receiver’s current selection with the specified DOM node.
- (void)replaceSelectionWithNode:(DOMNode *)node
Parameters
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.
Discussion
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.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– replaceSelectionWithText:
– replaceSelectionWithMarkupString:
– replaceSelectionWithArchive:
– deleteSelection
Declared In
WebView.h
replaceSelectionWithText:
Replaces the current selection with a string of text.
- (void)replaceSelectionWithText:(NSString *)text
Parameters
text
The text that replaces the current selection.
Discussion
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.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– replaceSelectionWithNode:
– replaceSelectionWithMarkupString:
– replaceSelectionWithArchive:
– deleteSelection
Declared In
WebView.h
resourceLoadDelegate
Returns the receiver’s resource load delegate.
- (id)resourceLoadDelegate
Return Value
A resource load delegate that conforms to the WebResourceLoadDelegate protocol.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– setResourceLoadDelegate:
Declared In
WebView.h
searchFor:direction:caseSensitive:wrap:
Searches 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
Parameters
string
The search string.
forward
If YES the direction of the search is forward; if NO, the direction is backward.
caseFlag
If YES if the search is case sensitive; otherwise, it is not.
wrapFlag
If YES if the search wraps; otherwise, it does not.
Return Value
YES if the search is successful; otherwise, NO.
Discussion
The search for string begins from the current selection and continues in the direction specified by forward. The search continues across all frames.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– applicationNameForUserAgent
– setCustomUserAgent:
– customUserAgent
Declared In
WebView.h
selectedDOMRange
Returns the range of the current selection.
- (DOMRange *)selectedDOMRange
Return Value
The range of the current selection. nil if nothing is selected.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– selectionAffinity
– setSelectedDOMRange:affinity:
– editableDOMRangeForPoint:
Declared In
WebView.h
selectedFrame
Returns the frame with the active selection.
- (WebFrame *)selectedFrame
Return Value
The frame that contains the first responder. If it doesn’t exist, the frame that contains a non-zero-length selection; otherwise, nil.
Availability
Available in Mac OS X v10.4.11 and later.
Declared In
WebView.h
selectionAffinity
Returns the current selection affinity.
- (NSSelectionAffinity)selectionAffinity
Return Value
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.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– selectedDOMRange
– setSelectedDOMRange:affinity:
Declared In
WebView.h
selectSentence:
Selects the entire sentence around the insertion point.
- (void)selectSentence:(id)sender
Parameters
sender
The object that sent this message.
Availability
Available in Mac OS X v10.4.11 and later.
Declared In
WebView.h
setApplicationNameForUserAgent:
Sets the application name used in the user-agent string.
- (void)setApplicationNameForUserAgent:(NSString *)applicationName
Parameters
applicationName
The application name to use in the user-agent string. The user-agent is used by websites to identify the client browser.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– applicationNameForUserAgent
– setCustomUserAgent:
– customUserAgent
Declared In
WebView.h
setContinuousSpellCheckingEnabled:
Sets whether the web view has continuous spell-checking enabled.
- (void)setContinuousSpellCheckingEnabled:(BOOL)flag
Parameters
flag
YES if the object should have continuous spell-checking enabled; otherwise, NO.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– isContinuousSpellCheckingEnabled
Declared In
WebView.h
setCustomTextEncodingName:
Sets the custom text encoding name.
- (void)setCustomTextEncodingName:(NSString *)encodingName
Parameters
encodingName
A text encoding name. If nil, the default encoding is restored.
Discussion
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.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– customTextEncodingName
Declared In
WebView.h
setCustomUserAgent:
Sets the receiver’s custom user-agent string.
- (void)setCustomUserAgent:(NSString *)userAgentString
Parameters
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.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– setApplicationNameForUserAgent:
– applicationNameForUserAgent
– customUserAgent
Declared In
WebView.h
setDownloadDelegate:
Sets the receiver's shared download delegate.
- (void)setDownloadDelegate:(id)delegate
Parameters
delegate
The download delegate that implements the WebDownload protocol.
Discussion
WebKit may create WebDownload objects automatically to handle downloads that start with a webpage or link.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– downloadDelegate
Declared In
WebView.h
setDrawsBackground:
Sets whether a default background is drawn when the webpage has no background set.
- (void)setDrawsBackground:(BOOL)drawsBackround
Parameters
drawsBackround
If YES, a default background is drawn; if NO, it is not.
Availability
Available in Mac OS X v10.4.11 and later.
Declared In
WebView.h
setEditable:
Sets whether the receiver allows the user to edit its HTML document.
- (void)setEditable:(BOOL)flag
Parameters
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.
Discussion
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.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– isEditable
Declared In
WebView.h
setEditingDelegate:
Sets the receiver’s editing delegate.
- (void)setEditingDelegate:(id)delegate
Parameters
delegate
The editing delegate for the web view that conforms to the WebEditingDelegate protocol.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– editingDelegate
Declared In
WebView.h
setFrameLoadDelegate:
Sets the receiver's frame load delegate.
- (void)setFrameLoadDelegate:(id)delegate
Parameters
delegate
A frame load delegate that conforms to the WebFrameLoadDelegate protocol.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– frameLoadDelegate
Declared In
WebView.h
setGroupName:
Sets the receiver's group name.
- (void)setGroupName:(NSString *)groupName
Parameters
groupName
An arbitrary identifier used to group related frames.
Discussion
You might use this method to set the group name of a WebView object after it is loaded from a nib file.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– initWithFrame:frameName:groupName:
– groupName
Declared In
WebView.h
setHostWindow:
Sets the receiver's host window.
- (void)setHostWindow:(NSWindow *)hostWindow
Parameters
hostWindow
A host window.
Discussion
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.
Note: Plug-ins and JavaScript depend on a window to function properly even if the web view is not in an actual window.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– hostWindow
Declared In
WebView.h
setMainFrameURL:
Sets the URL that the main frame loads.
- (void)setMainFrameURL:(NSString *)URLString
Parameters
URLString
The main frame URL string.
Discussion
This method is functionally equivalent to invoking [[webView mainFrame] loadRequest:[NSURLRequest requestWithURL: [NSURL URLWithString:URLString]]].
Availability
Available in Mac OS X v10.4.11 and later.
Declared In
WebView.h
setMaintainsBackForwardList:
Sets whether to use a back-forward list.
- (void)setMaintainsBackForwardList:(BOOL)flag
Parameters
flag
If NO, clears the back-forward list and release the page cache; otherwise, it does not.
Discussion
The back-forward list maintains a page cache, so applications that do not use the goForward or goBack methods should disable it.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– backForwardList
Declared In
WebView.h
setMediaStyle:
Sets the receiver’s CSS media property.
- (void)setMediaStyle:(NSString *)mediaStyle
Parameters
mediaStyle
The CSS media property for the receiver.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– mediaStyle
Declared In
WebView.h
setPolicyDelegate:
Sets the receiver's policy delegate.
- (void)setPolicyDelegate:(id)delegate
Parameters
delegate
A policy delegate that conforms to the WebPolicyDelegate protocol.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– policyDelegate
Declared In
WebView.h
setPreferences:
Sets the receiver’s preferences.
- (void)setPreferences:(WebPreferences *)preferences
Parameters
preferences
The web view’s preferences.
Discussion
Typically, you do not invoke this method directly. Use the setPreferencesIdentifier: method to change the receiver’s preferences.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– preferences
Declared In
WebView.h
setPreferencesIdentifier:
Sets the receiver's preferences identifier, creating a preferences object if needed.
- (void)setPreferencesIdentifier:(NSString *)anIdentifier
Parameters
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.
Discussion
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.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– preferencesIdentifier
– setAutosaves:
Declared In
WebView.h
setResourceLoadDelegate:
Sets the receiver's resource load delegate.
- (void)setResourceLoadDelegate:(id)delegate
Parameters
delegate
A resource load delegate that conforms to the WebResourceLoadDelegate protocol.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– resourceLoadDelegate
Declared In
WebView.h
setSelectedDOMRange:affinity:
Selects a range of nodes.
- (void)setSelectedDOMRange:(DOMRange *)range affinity:(NSSelectionAffinity)selectionAffinity
Parameters
range
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.
selectionAffinity
See the selectionAffinity method for information on selection affinity.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– selectedDOMRange
– selectionAffinity
– editableDOMRangeForPoint:
Declared In
WebView.h
setShouldCloseWithWindow:
Sets whether the web view should close when its window or host window closes.
- (void)setShouldCloseWithWindow:(BOOL)close
Parameters
close
If YES, the web view should close; otherwise, it should not.
Availability
Available in Mac OS X v10.4.11 and later.
Declared In
WebView.h
setShouldUpdateWhileOffscreen:
Sets whether the web view should update even when it is not in a window that is currently visible.
- (void)setShouldUpdateWhileOffscreen:(BOOL)updateWhileOffscreen
Parameters
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.
Availability
Available in Mac OS X v10.6 and later.
See Also
– shouldUpdateWhileOffscreen
Declared In
WebView.h
setSmartInsertDeleteEnabled:
Sets whether the receiver should insert or delete spaces around selected words to preserve proper spacing and punctuation.
- (void)setSmartInsertDeleteEnabled:(BOOL)flag
Parameters
flag
If YES, the receiver performs smart insert and delete; if NO, it inserts and deletes exactly what’s selected.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– smartInsertDeleteEnabled
Declared In
WebView.h
setTextSizeMultiplier:
Change the font size multiplier for text displayed in web frame view objects managed by the receiver.
- (void)setTextSizeMultiplier:(float)multiplier
Parameters
multiplier
A fractional percentage value where 1.0 denotes 100%.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– textSizeMultiplier
Declared In
WebView.h
setTypingStyle:
Sets the receiver’s CSS typing style.
- (void)setTypingStyle:(DOMCSSStyleDeclaration *)style
Parameters
style
The receiver’s CSS typing style.
Discussion
The typing style is reset automatically when the receiver’s selection changes.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– typingStyle
– computedStyleForElement:pseudoElement:
– applyStyle:
Declared In
WebView.h
setUIDelegate:
Sets the receiver's user interface delegate.
- (void)setUIDelegate:(id)delegate
Parameters
delegate
A user interface delegate that conforms to the WebUIDelegate protocol.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– UIDelegate
Declared In
WebView.h
shouldCloseWithWindow
Returns whether the web view should close when its window or host window closes.
- (BOOL)shouldCloseWithWindow
Return Value
If YES, the web view should close; otherwise, it should not.
Availability
Available in Mac OS X v10.4.11 and later.
Declared In
WebView.h
shouldUpdateWhileOffscreen
Returns whether the web view should update even when it is not visible.
- (BOOL)shouldUpdateWhileOffscreen
Return Value
YES if it should update even when it is not visible; otherwise, NO.
Availability
Available in Mac OS X v10.6 and later.
See Also
– setShouldUpdateWhileOffscreen:
Declared In
WebView.h
showGuessPanel:
An action method that shows a spelling correction panel.
- (void)showGuessPanel:(id)sender
Parameters
sender
The object that sent this message.
Discussion
This action method opens the Spelling panel, allowing the user to make a correction during spell checking.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– checkSpelling:
Declared In
WebView.h
smartInsertDeleteEnabled
Returns whether smart-space insertion and deletion is enabled.
- (BOOL)smartInsertDeleteEnabled
Return Value
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.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– setSmartInsertDeleteEnabled:
Declared In
WebView.h
spellCheckerDocumentTag
Returns the spell-checker document tag for this document.
- (NSInteger)spellCheckerDocumentTag
Return Value
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.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
spellCheckerDocumentTag (NSTextView)
Declared In
WebView.h
startSpeaking:
An action method that starts speaking the selected text or all text if there’s no selection.
- (void)startSpeaking:(id)sender
Parameters
sender
The object that sent this message.
Discussion
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.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– stopSpeaking:
Declared In
WebView.h
stopLoading:
An action method that stops the loading of any web frame content managed by the receiver.
- (void)stopLoading:(id)sender
Parameters
sender
The object that sent this message.
Discussion
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.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
Declared In
WebView.h
stopSpeaking:
An action method that stops speaking that is in progress.
- (void)stopSpeaking:(id)sender
Parameters
sender
The object that sent this message.
Discussion
This action method stops speech that was previously started with startSpeaking:. This method behaves similar to the stopSpeaking: method in NSTextView.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– startSpeaking:
Declared In
WebView.h
stringByEvaluatingJavaScriptFromString:
Returns the result of running a script.
- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script
Parameters
script
The script to run.
Return Value
The result of running a JavaScript specified by script, or an empty string if the script failed.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
Related Sample Code
WebKitPluginWithSimpleGUI
Declared In
WebView.h
styleDeclarationWithText:
Returns the CSS style declaration for the specified text.
- (DOMCSSStyleDeclaration *)styleDeclarationWithText:(NSString *)text
Parameters
text
The text whose style declaration is returned.
Return Value
The style declaration for text.
Availability
Available in Mac OS X v10.3.9 and later.
Declared In
WebView.h
supportsTextEncoding
Returns whether the document view supports different text encodings.
- (BOOL)supportsTextEncoding
Return Value
YES if the receiver’s document view can support different text encodings; otherwise, NO.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
Declared In
WebView.h
takeStringURLFrom:
Sets the receiver’s current location by obtaining a URL string from the sender.
- (void)takeStringURLFrom:(id)sender
Parameters
sender
The object that sent this message.
Discussion
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.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– loadRequest: (WebFrame)
Declared In
WebView.h
textSizeMultiplier
Returns the font size multiplier for text displayed in web frame view objects managed by the receiver.
- (float)textSizeMultiplier
Return Value
The font size multiplier, a fractional percentage value where 1.0 denotes 100%.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– setTextSizeMultiplier:
Declared In
WebView.h
toggleContinuousSpellChecking:
Toggles whether continuous spell checking is available.
- (void)toggleContinuousSpellChecking:(id)sender
Parameters
sender
The object that sent this message.
Availability
Available in Mac OS X v10.4.11 and later.
Declared In
WebView.h
toggleSmartInsertDelete:
Toggles whether spaces around selected words are inserted or deleted to preserve proper spacing and punctuation.
- (void)toggleSmartInsertDelete:(id)sender
Parameters
sender
The object that sent this message.
Availability
Available in Mac OS X v10.4.11 and later.
Declared In
WebView.h
typingStyle
Returns the receiver’s CSS typing style.
- (DOMCSSStyleDeclaration *)typingStyle
Return Value
The receiver’s CSS typing style.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– setTypingStyle:
– computedStyleForElement:pseudoElement:
– applyStyle:
Declared In
WebView.h
UIDelegate
Returns the receiver's user interface delegate.
- (id)UIDelegate
Return Value
A user interface delegate that conforms to the WebUIDelegate protocol.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– setUIDelegate:
Declared In
WebView.h
undoManager
Returns the receiver’s undo manager.
- (NSUndoManager *)undoManager
Return Value
The receiver’s undo manager.
Availability
Available in Mac OS X v10.3.9 and later.
Declared In
WebView.h
userAgentForURL:
Returns the appropriate user-agent string for a given URL.
- (NSString *)userAgentForURL:(NSURL *)URL
Parameters
URL
The URL that you need the user-agent string for.
Return Value
The user-agent string for a given URL. The user-agent string is used by websites to identify the client browser.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– setCustomUserAgent:
– customUserAgent
Declared In
WebView.h
windowScriptObject
Returns the receiver’s window object from the scripting environment.
- (WebScriptObject *)windowScriptObject
Return Value
The receiver’s window object.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– objectForWebScript (WebPlugIn) (WebFrameLoadDelegate)
– webView:windowScriptObjectAvailable:
Related Sample Code
QT Capture Widget
WebKitPluginWithJavaScript
Declared In
WebView.h
writeElement:withPasteboardTypes:toPasteboard:
Writes an element to the pasteboard using a list of types.
- (void)writeElement:(NSDictionary *)element withPasteboardTypes:(NSArray *)types toPasteboard:(NSPasteboard *)pasteboard
Parameters
element
The element to write to the pasteboard.
types
The pasteboard types to use for the element.
pasteboard
The pasteboard to use for writing.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– writeSelectionWithPasteboardTypes:toPasteboard:
Declared In
WebView.h
writeSelectionWithPasteboardTypes:toPasteboard:
Writes the receiver’s current selection to a pasteboard using a list of types.
- (void)writeSelectionWithPasteboardTypes:(NSArray *)types toPasteboard:(NSPasteboard *)pasteboard
Parameters
types
The pasteboard types to use for the selection.
pasteboard
The pasteboard to use for writing.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– writeElement:withPasteboardTypes:toPasteboard:
Declared In
WebView.h
Constants
Element Dictionary Keys
Predefined 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;
Constants
WebElementDOMNodeKey
The DOMNode for this element.
Available in Mac OS X v10.3 and later.
Declared in WebView.h.
WebElementFrameKey
The WebFrame object associated with this element.
Available in Mac OS X v10.2 and later.
Declared in WebView.h.
WebElementImageAltStringKey
An NSString of the ALT attribute of an image element.
Available in Mac OS X v10.2 and later.
Declared in WebView.h.
WebElementImageKey
An NSImage representing an image element.
Available in Mac OS X v10.2 and later.
Declared in WebView.h.
WebElementImageRectKey
An NSValue containing an NSRect, the size of an image element.
Available in Mac OS X v10.2 and later.
Declared in WebView.h.
WebElementImageURLKey
An NSURL containing the location of an image element.
Available in Mac OS X v10.2 and later.
Declared in WebView.h.
WebElementIsSelectedKey
An 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.
WebElementLinkURLKey
An 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.
WebElementLinkTargetFrameKey
The WebFrame object associated with the target of the anchor.
Available in Mac OS X v10.2 and later.
Declared in WebView.h.
WebElementLinkTitleKey
An NSString containing the title of an anchor.
Available in Mac OS X v10.2 and later.
Declared in WebView.h.
WebElementLinkLabelKey
An NSString containing the text within an anchor.
Available in Mac OS X v10.2 and later.
Declared in WebView.h.
Discussion
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.
Notifications
WebViewDidBeginEditingNotification
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.
Availability
Available in Mac OS X v10.3.9 and later.
Declared In
WebView.h
WebViewDidChangeNotification
Posted 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.
Availability
Available in Mac OS X v10.3.9 and later.
Declared In
WebView.h
WebViewDidChangeSelectionNotification
Posted 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.
Availability
Available in Mac OS X v10.3.9 and later.
Declared In
WebView.h
WebViewDidChangeTypingStyleNotification
Posted 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.
Availability
Available in Mac OS X v10.3.9 and later.
See Also
– setTypingStyle:
Declared In
WebView.h
WebViewDidEndEditingNotification
Posted 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.
Availability
Available in Mac OS X v10.3.9 and later.
Declared In
WebView.h
WebViewProgressEstimateChangedNotification
Posted 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.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– estimatedProgress
Declared In
WebView.h
WebViewProgressFinishedNotification
Posted 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.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– estimatedProgress
Declared In
WebView.h
WebViewProgressStartedNotification
Posted 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.
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
See Also
– estimatedProgress
Declared In
WebView.h