| 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
WebPreferences.hReturns whether or not the web view allows animated images to loop.
- (BOOL)allowsAnimatedImageLooping
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
– allowsAnimatedImageLooping– setAllowsAnimatedImages:– loadsImagesAutomatically– setLoadsImagesAutomatically:WebPreferences.hReturns whether or not the web view allows plug-ins.
- (BOOL)arePlugInsEnabled
WebPreferences.hReturns whether or not the receiver’s attributes are automatically stored in the user defaults database.
- (BOOL)autosaves
WebPreferences.hReturns the cursive font family for the web view.
- (NSString *)cursiveFontFamily
WebPreferences.hReturns the default fixed font size for the web view.
- (int)defaultFixedFontSize
WebPreferences.hReturns the default font size for the web view.
- (int)defaultFontSize
WebPreferences.hReturns the default text encoding for the web view.
- (NSString *)defaultTextEncodingName
WebPreferences.hReturns the fantasy font family for the web view.
- (NSString *)fantasyFontFamily
WebPreferences.hReturns the fixed font family for the web view.
- (NSString *)fixedFontFamily
WebPreferences.hReturns the receiver’s identifier.
- (NSString *)identifier
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
WebPreferences.hReturns whether or not JavaScript is enabled for the web view.
- (BOOL)isJavaScriptEnabled
WebPreferences.hReturns whether or not JavaScript can open windows automatically for the web view.
- (BOOL)javaScriptCanOpenWindowsAutomatically
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
– setLoadsImagesAutomatically:– allowsAnimatedImages– setAllowsAnimatedImages:– allowsAnimatedImageLooping– setAutosaves:WebPreferences.hReturns the minimum font size for the web view.
- (int)minimumFontSize
The default value is 1, meaning the minimum font size will only be constrained by the minimum logical font size.
WebPreferences.hReturns the minimum logical font size for the web view.
- (int)minimumLogicalFontSize
The minimum logical font size is the smallest font size that will display in a Web Kit view when the content’s font size is not explicitly defined. Its default value is a 9-point font size.
WebPreferences.hReturns whether or not private browsing is enabled.
- (BOOL)privateBrowsingEnabled
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
WebPreferences.hReturns the serif font family for the web view.
- (NSString *)serifFontFamily
WebPreferences.hSets whether or not the receiver allows animated images to loop.
- (void)setAllowsAnimatedImageLooping:(BOOL)flag
If flag is YES the web view will loop animated images, otherwise it will display them as static images. 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
If flag is YES the web view allows animated images, otherwise it does not.
– 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
If flag is YES the receiver’s attributes are automatically stored in the user defaults database, otherwise they are not. The default value is NO.
WebPreferences.hSets the cursive font family of the web view.
- (void)setCursiveFontFamily:(NSString *)family
WebPreferences.hSets the default fixed font size of the web view.
- (void)setDefaultFixedFontSize:(int)size
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 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
WebPreferences.hSets the fantasy font family of the web view.
- (void)setFantasyFontFamily:(NSString *)family
WebPreferences.hSets the fixed font family of the web view.
- (void)setFixedFontFamily:(NSString *)family
WebPreferences.hSets whether or not the web view allows Java.
- (void)setJavaEnabled:(BOOL)flag
If flag is YES the web view allows Java, otherwise it does not.
WebPreferences.hSets whether or not the web view allows JavaScript to open windows automatically.
- (void)setJavaScriptCanOpenWindowsAutomatically:(BOOL)flag
If flag is YES the web view allows JavaScript to open windows automatically, otherwise it does not. 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
If flag is YES the web view allows JavaScript, otherwise it does not.
WebPreferences.hSets whether or not the web view allows images to be loaded automatically.
- (void)setLoadsImagesAutomatically:(BOOL)flag
If flag is YES the web view allows images to be loaded automatically, otherwise it does not.
– loadsImagesAutomatically– allowsAnimatedImages– setAllowsAnimatedImages:– allowsAnimatedImageLooping– setAutosaves:WebPreferences.hSets the minimum font size of the web view.
- (void)setMinimumFontSize:(int)size
You should use this method to explicitly set the minimum display font size for the web view. 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 is the smallest font size that will display in a web view when the content’s font size is not explicitly defined. 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
If flag is YES the web view allows plug-ins, otherwise it does not.
WebPreferences.hSets whether or not private browsing is enabled.
- (void)setPrivateBrowsingEnabled:(BOOL)flag
If flag is YES, the web view will 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
WebPreferences.hSets the serif font family of the web view.
- (void)setSerifFontFamily:(NSString *)family
WebPreferences.hSets whether or not the web view should include backgrounds when printing.
- (void)setShouldPrintBackgrounds:(BOOL)flag
If flag is YES the web view prints the backgrounds, otherwise it does not.
WebPreferences.hSets the standard font family of the web view.
- (void)setStandardFontFamily:(NSString *)family
WebPreferences.hSets whether or not the web view will focus control on links when tabbing.
- (void)setTabsToLinks:(BOOL)flag
If flag is YES the web view tabs to links, otherwise it does not.
WebPreferences.hSets whether or not the web view enables user style sheets.
- (void)setUserStyleSheetEnabled:(BOOL)flag
If flag is YES the web view enables user style sheets, otherwise it does not.
WebPreferences.hSets the location of the user style sheet.
- (void)setUserStyleSheetLocation:(NSURL *)URL
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.hReturns whether the web view should include backgrounds when printing.
- (BOOL)shouldPrintBackgrounds
WebPreferences.hReturns the standard font family used by the web view.
- (NSString *)standardFontFamily
WebPreferences.hReturns whether or not the tab key will focus links.
- (BOOL)tabsToLinks
WebPreferences.hReturns whether the web view enables user style sheets.
- (BOOL)userStyleSheetEnabled
WebPreferences.hReturns the location of the user style sheet.
- (NSURL *)userStyleSheetLocation
WebPreferences.h
Posted 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.h
Last updated: 2006-05-23