| 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 | WebPreferences.h |
WebPreferences encapsulates the preferences you can change per WebView object. These preferences include font, text encoding, and image settings. Normally a WebView object uses the standard preferences returned by the standardPreferences class method. However, you can modify the preferences for individual WebView instances too. Use the setPreferencesIdentifier: WebView method to change a WebView object’s preferences, or to share preferences between WebView objects. Use the setAutosaves: method to specify if the preferences object should be automatically saved to the user defaults database.
WebPreferences also manages the font preferences for a web view. You can set custom font families for each of the primary web font styles (standard, serif, sans-serif, cursive, and fantasy) as well as their font sizes. The font size preferences alter the display font sizes in a certain way. If the HTML or CSS in the web view’s content specifies font sizes in a relative fashion (such as font size=-1 in HTML or font-size: medium in CSS), the default font size settings (set by the font size methods prefaced with “default”) have an effect. They do not have an effect for font sizes specified absolutely. The values specified by the minimum font size settings (set by the font size methods prefaced with “minimum”) override all the HTML and CSS font size definitions, and so have an effect on the entirety of the content. The values specified by the minimum logical font size settings (set by the font size methods prefaced with “minimumLogical”) affect all relative font size declarations for HTML and CSS, but also override any CSS font size declarations in the content, whether they are relative or absolute.
The font size for a web view is different than its logical font size. The minimum logical font size, for example, is the absolute minimum size at which the font will display onscreen. This is meant to be a functional boundary and not a style boundary. For example, the default value for a web view’s minimum logical font size is 9 points, because typical web content looks good on Mac OS X at font sizes of 9 point and above. The constraint assures that web content will always look good in a web view. If you know that your content will look good only at 12 points or above, you should change the minimum font size to 12 points and leave the minimum logical font size alone. This will assure that your content will never display at sizes less than 12 points, but the functional font size boundary of the web view will remain at 9 points to prevent any chance of displaying unnecessarily small text.
– setJavaScriptEnabled:
– isJavaScriptEnabled
– setJavaScriptCanOpenWindowsAutomatically:
– javaScriptCanOpenWindowsAutomatically
– setUserStyleSheetEnabled:
– userStyleSheetEnabled
– setUserStyleSheetLocation:
– userStyleSheetLocation
– setCursiveFontFamily:
– cursiveFontFamily
– setFantasyFontFamily:
– fantasyFontFamily
– setFixedFontFamily:
– fixedFontFamily
– setSansSerifFontFamily:
– sansSerifFontFamily
– setSerifFontFamily:
– serifFontFamily
– setStandardFontFamily:
– standardFontFamily
– setDefaultFixedFontSize:
– defaultFixedFontSize
– setDefaultFontSize:
– defaultFontSize
– setMinimumFontSize:
– minimumFontSize
– setMinimumLogicalFontSize:
– minimumLogicalFontSize
– setAllowsAnimatedImageLooping:
– allowsAnimatedImageLooping
– setAllowsAnimatedImages:
– allowsAnimatedImages
– setLoadsImagesAutomatically:
– loadsImagesAutomatically
Returns the standard set of preferences that may be used by all WebView objects.
+ (WebPreferences *)standardPreferences
A WebPreferences object containing the standard set of preferences that may be used by all WebView objects.
WebPreferences.hReturns whether or not the web view allows animated images to loop.
- (BOOL)allowsAnimatedImageLooping
YES if the web view is configured to loop animated images, NO otherwise.
The number of times that an image loops is determined by parameters of the image file itself and cannot be set in the web view.
– allowsAnimatedImageLooping– setAllowsAnimatedImages:– setAllowsAnimatedImages:– loadsImagesAutomatically– setLoadsImagesAutomatically:WebPreferences.hReturns whether or not the web view allows animated images.
- (BOOL)allowsAnimatedImages
YES if the web view allows animated images, otherwise NO.
– allowsAnimatedImageLooping– setAllowsAnimatedImages:– loadsImagesAutomatically– setLoadsImagesAutomatically:WebPreferences.hReturns whether or not the web view allows plug-ins.
- (BOOL)arePlugInsEnabled
YES if the web view allows plug-ins, otherwise NO.
WebPreferences.hReturns whether or not the receiver’s attributes are automatically stored in the user defaults database.
- (BOOL)autosaves
YES if the receiver’s attributes are automatically stored, NO otherwise.
WebPreferences.hReturns the cache model for a web view.
- (WebCacheModel)cacheModel
The cache model for the web views associated with the receiver. Possible values are described in WebCacheModel.
WebPreferences.hReturns the cursive font family for the web view.
- (NSString *)cursiveFontFamily
The default font used for cursive text.
This preference affects text whose properties indicate that it should be displayed in a cursive font but do not specify a particular font.
WebPreferences.hReturns the default fixed font size for the web view.
- (int)defaultFixedFontSize
The default font size used for content displayed in a fixed font if no font size is specified.
WebPreferences.hReturns the default font size for the web view.
- (int)defaultFontSize
The default font size used for content displayed in a fixed font if no font size or font family is specified.
WebPreferences.hReturns the default text encoding for the web view.
- (NSString *)defaultTextEncodingName
The default text encoding used when interpreting content whose encoding is not specified.
WebPreferences.hReturns the fantasy font family for the web view.
- (NSString *)fantasyFontFamily
The font family used as the default for content marked with a fantasy font.
This preference affects text whose properties indicate that it should be displayed in a fantasy font but do not specify a particular font.
WebPreferences.hReturns the fixed font family for the web view.
- (NSString *)fixedFontFamily
The font family used as the default for content marked with a fixed font.
This preference affects text whose properties indicate that it should be displayed in a fixed font but do not specify a particular font.
WebPreferences.hReturns the receiver’s identifier.
- (NSString *)identifier
The identifier of the WebPreferences object.
WebPreferences.hReturns an initialized WebPreferences object, creating one if it does not exist.
- (id)initWithIdentifier:(NSString *)anIdentifier
This method returns either the receiver initialized with anIdentifier, or another WebPreferences object matching anIdentifier if it exists.
The anIdentifier argument should be a unique identifier—it will be prepended to the keys used to store the receiver’s attributes in the user defaults database. WebView objects can share instances of WebPreferences by using the same preferences identifier.
Typically, you do not invoke this method directly. Instead, you set the preferences identifier by sending a setPreferencesIdentifier: message to your WebView object. This method is the designated initializer for the WebPreferences class.
WebPreferences.hReturns whether or not Java is enabled for the web view.
- (BOOL)isJavaEnabled
YES if the view allows Java, NO otherwise.
WebPreferences.hReturns whether or not JavaScript is enabled for the web view.
- (BOOL)isJavaScriptEnabled
YES if the web view allows JavaScript, otherwise NO.
WebPreferences.hReturns whether or not JavaScript can open windows automatically for the web view.
- (BOOL)javaScriptCanOpenWindowsAutomatically
YES if the web view allows JavaScript to open windows automatically, otherwise NO.
Explicit calls to a JavaScript window opener that are activated by user action (such as a button click) are not affected by this setting.
WebPreferences.hReturns whether images are loaded automatically for the web view.
- (BOOL)loadsImagesAutomatically
YES if the web view allows images to be loaded automatically, otherwise NO.
– setLoadsImagesAutomatically:– allowsAnimatedImages– setAllowsAnimatedImages:– allowsAnimatedImageLooping– setAutosaves:WebPreferences.hReturns the minimum font size for the web view.
- (int)minimumFontSize
The minimum font size that will be used for content regardless of the font size specified by that content.
The default value is 1, meaning that the minimum font size is constrained only by the minimum logical font size.
WebPreferences.hReturns the minimum logical font size for the web view.
- (int)minimumLogicalFontSize
The minimum logical font size used by the web view.
The minimum logical font size is the smallest font size that will display in a web view when the content’s font size is imprecisely specified. This includes content with logical sizes (such as small) or with a font size specified as a percentage of the default.
Its default value is a 9-point font size.
WebPreferences.hReturns whether or not private browsing is enabled.
- (BOOL)privateBrowsingEnabled
YES if private browsing is enabled, otherwise NO.
Private browsing prevents the web view from maintaining any history, cache, or AutoFill information for the pages being visited.
WebPreferences.hReturns the sans serif font family for the web view.
- (NSString *)sansSerifFontFamily
The font family used as the default for content marked with a sans-serif font.
This preference affects text whose properties indicate that it should be displayed in a sans-serif font but do not specify a particular font.
WebPreferences.hReturns the serif font family for the web view.
- (NSString *)serifFontFamily
The font family used as the default for content marked with a serif font.
This preference affects text whose properties indicate that it should be displayed in a serif font but do not specify a particular font.
WebPreferences.hSets whether or not the receiver allows animated images to loop.
- (void)setAllowsAnimatedImageLooping:(BOOL)flag
YES if the web view should loop animated images, NO otherwise.
If image looping is disabled, the web view displays it as a static image. The number of times that an image loops is determined by parameters of the image file itself and cannot be set in the web view.
– allowsAnimatedImageLooping– allowsAnimatedImages– setAllowsAnimatedImages:– loadsImagesAutomatically– setLoadsImagesAutomatically:WebPreferences.hSets whether or not the receiver allows animated images.
- (void)setAllowsAnimatedImages:(BOOL)flag
Set to YES if the web view should allow animated images, otherwise NO.
– allowsAnimatedImages– setAutosaves:– allowsAnimatedImageLooping– loadsImagesAutomatically– setLoadsImagesAutomatically:WebPreferences.hSets whether or not the receiver’s attributes are stored in the user defaults database.
- (void)setAutosaves:(BOOL)flag
Set to YES if the receiver’s attributes should be automatically stored in the user defaults database, NO otherwise.
The default value is NO.
WebPreferences.hSets the cache model for the web views associated with the receiver.
- (void)setCacheModel:(WebCacheModel)cacheModel
The cache model for the web views associated with the receiver. Possible values are described in WebCacheModel.
Set this property to optimize WebKit's cache footprint (on disk and in memory) to best fit the use of the web view. If a web view is used only for a single webpage, use the WebCacheModelDocumentViewer constant instead.
WebPreferences.hSets the cursive font family of the web view.
- (void)setCursiveFontFamily:(NSString *)family
The font family to use as the default font for cursive text.
This preference affects text whose properties indicate that it should be displayed in a cursive font but do not specify a particular font.
WebPreferences.hSets the default fixed font size of the web view.
- (void)setDefaultFixedFontSize:(int)size
The default font size to use for content displayed in a fixed font if no font size is specified.
The font size specified by size should always be greater than zero.
WebPreferences.hSets the default font size of the web view.
- (void)setDefaultFontSize:(int)size
The default font size to use for content displayed in a fixed font if no font size or font family is specified.
The font size specified by size should always be greater than zero.
WebPreferences.hSets the default text encoding of the web view.
- (void)setDefaultTextEncodingName:(NSString *)encoding
The default text encoding to use when interpreting content whose encoding is not specified.
WebPreferences.hSets the fantasy font family of the web view.
- (void)setFantasyFontFamily:(NSString *)family
The font family to use as the default for content marked with a fantasy font.
This preference affects text whose properties indicate that it should be displayed in a fantasy font but do not specify a particular font.
WebPreferences.hSets the fixed font family of the web view.
- (void)setFixedFontFamily:(NSString *)family
The font family to use as the default for content marked with a fixed font.
This preference affects text whose properties indicate that it should be displayed in a fixed font but do not specify a particular font.
WebPreferences.hSets whether or not the web view allows Java.
- (void)setJavaEnabled:(BOOL)flag
Set to YES to indicate that the web view allows Java, otherwise NO.
WebPreferences.hSets whether or not the web view allows JavaScript to open windows automatically.
- (void)setJavaScriptCanOpenWindowsAutomatically:(BOOL)flag
Set to YES if the web view should allow JavaScript to open windows automatically, otherwise NO.
Explicit calls to a JavaScript window opener that are activated by user action (such as a button click) are not affected by this setting.
WebPreferences.hSets whether or not the web view allows JavaScript.
- (void)setJavaScriptEnabled:(BOOL)flag
Set to YES if the web view should allow JavaScript, otherwise NO.
WebPreferences.hSets whether or not the web view allows images to be loaded automatically.
- (void)setLoadsImagesAutomatically:(BOOL)flag
YES if the web view should allow images to be loaded automatically, otherwise NO.
– loadsImagesAutomatically– allowsAnimatedImages– setAllowsAnimatedImages:– allowsAnimatedImageLooping– setAutosaves:WebPreferences.hSets the minimum font size of the web view.
- (void)setMinimumFontSize:(int)size
The minimum font size to use for content regardless of the font size specified by that content.
This method sets the minimum display font size for the web view, overriding all content-specified styles, including explicitly specified font sizes.
The font size specified by size should always be greater than zero.
WebPreferences.hSets the minimum logical font size of the web view.
- (void)setMinimumLogicalFontSize:(int)size
The minimum logical font size that the web view should use.
The minimum logical font size is the smallest font size that will display in a web view when the content’s font size is imprecisely specified. This includes content with logical sizes (such as small) or with a font size specified as a percentage of the default.
Most clients will not want to use this method; rather, explicitly set the minimum display font size using the setMinimumFontSize: method.
The font size specified by size should always be greater than zero.
WebPreferences.hSets whether or not the web view allows plug-ins.
- (void)setPlugInsEnabled:(BOOL)flag
Set to YES if the web view should allow plug-ins, otherwise NO.
WebPreferences.hSets whether or not private browsing is enabled.
- (void)setPrivateBrowsingEnabled:(BOOL)flag
YES if private browsing should be enabled, otherwise NO.
If private browsing is enabled, the web view does not store information about the websites the user visits. Private browsing prevents the web view from maintaining any history, cache, or AutoFill information for the pages being visited.
WebPreferences.hSets the sans serif font family of the web view.
- (void)setSansSerifFontFamily:(NSString *)family
The font family to useas the default for content marked with a sans-serif font.
This preference affects text whose properties indicate that it should be displayed in a sans-serif font but do not specify a particular font.
WebPreferences.hSets the serif font family of the web view.
- (void)setSerifFontFamily:(NSString *)family
The font family to use as the default for content marked with a serif font.
This preference affects text whose properties indicate that it should be displayed in a serif font but do not specify a particular font.
WebPreferences.hSets whether or not the web view should include backgrounds when printing.
- (void)setShouldPrintBackgrounds:(BOOL)flag
Set to YES if the web view should print backgrounds, otherwise NO.
WebPreferences.hSets the standard font family of the web view.
- (void)setStandardFontFamily:(NSString *)family
The font family to use as the default for content that does not specify a font.
This preference affects text whose properties do not indicate that they should be displayed in a particular font or class of fonts (such as sans-serif).
WebPreferences.hSets whether or not the web view will focus control on links when tabbing.
- (void)setTabsToLinks:(BOOL)flag
YES if the user is able to navigate to links by pressing the tab key, NO otherwise.
WebPreferences.hSets whether or not user style sheets are enabled in the web view.
- (void)setUserStyleSheetEnabled:(BOOL)flag
Set to YES if the user style sheets should be enabled in the web view, otherwise NO.
WebPreferences.hSets the location of the user style sheet.
- (void)setUserStyleSheetLocation:(NSURL *)URL
An NSURL object containing the location of the user style sheet.
The user style sheet will override all existing CSS definitions on the page. setUserStyleSheetEnabled: must have already been set to YES for this method to have an effect.
WebPreferences.hSets whether the web views associated with the receiver should use the shared page cache.
- (void)setUsesPageCache:(BOOL)usesPageCache
YES if the web views should use a page cache; otherwise, NO.
Pages are cached when they are added to a back-forward list, and removed from the cache when they are removed from a back-forward list. Because the page cache is global, caching a page in one back-forward list may cause a page in another back-forward list to be removed from the cache.
WebPreferences.hReturns whether the web view should include backgrounds when printing.
- (BOOL)shouldPrintBackgrounds
YES if the web view prints backgrounds, otherwise NO.
WebPreferences.hReturns the standard font family used by the web view.
- (NSString *)standardFontFamily
The font family used as the default for content that does not specify a font.
This preference affects text whose properties do not indicate that they should be displayed in a particular font or class of fonts (such as sans-serif).
WebPreferences.hReturns whether or not the tab key will focus links.
- (BOOL)tabsToLinks
YES if the user should be able to navigate to links by pressing the tab key, NO otherwise.
WebPreferences.hReturns whether user style sheets are enabled in the web view.
- (BOOL)userStyleSheetEnabled
YES if the user style sheets are enabled in the web view, otherwise NO.
WebPreferences.hReturns the location of the user style sheet.
- (NSURL *)userStyleSheetLocation
An NSURL object containing the location of the user style sheet.
WebPreferences.hReturns whether the web views associated with the receiver should use the shared page cache.
- (BOOL)usesPageCache
YES if the web views should use a page cache; otherwise, NO.
WebPreferences.hSpecifies the caching model for a web view.
enum {
WebCacheModelDocumentViewer = 0,
WebCacheModelDocumentBrowser = 1,
WebCacheModelPrimaryWebBrowser = 2
};
typedef NSUInteger WebCacheModel;
WebCacheModelDocumentViewerReleases resources when they are no longer referenced and caches remote resources on disk. This model is appropriate for displaying a static document with no navigation user interface. This is the most memory-efficient model.
Available in Mac OS X v10.5 and later.
Declared in WebPreferences.h.
WebCacheModelDocumentBrowserCaches a reasonable number of resources and previously viewed documents in memory and on disk. This model is appropriate for displaying and navigating between multiple documents.
Available in Mac OS X v10.5 and later.
Declared in WebPreferences.h.
WebCacheModelPrimaryWebBrowserCaches a large number of resources and previously viewed documents in memory and on disk. This model is appropriate for a web view that behaves like a web browser.
Available in Mac OS X v10.5 and later.
Declared in WebPreferences.h.
WebPreferences.hPosted when the web preference settings are changed.
The notification object is the WebPreferences object that changed. This notification does not contain a userInfo dictionary.
WebPreferences.hLast updated: 2009-08-19