Class

WebPreferences

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 preferencesIdentifier WebView method to change a WebView object’s preferences, or to share preferences between WebView objects. Use the autosaves method to specify if the preferences object should be automatically saved to the user defaults database.

Declaration

@interface WebPreferences : NSObject

Overview

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 in macOS 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.

Topics

Getting the Standard Preferences

+ standardPreferences

Returns the standard set of preferences that may be used by all WebView objects.

Initializing Preferences

- initWithIdentifier:

Returns an initialized WebPreferences object, creating one if it does not exist.

Getting the Identifier

identifier

The receiver’s identifier.

Saving Preferences to the User Defaults Database

autosaves

A Boolean that indicates whether or not the receiver’s attributes are automatically stored in the user defaults database.

Enabling Java

javaEnabled

A Boolean that indicates whether or not the web view allows Java.

Enabling JavaScript

javaScriptEnabled

A Boolean that indicates whether or not the web view allows JavaScript.

javaScriptCanOpenWindowsAutomatically

A Boolean that indicates whether or not the web view allows JavaScript to open windows automatically.

Enabling Plug-ins

plugInsEnabled

A Boolean that indicates whether or not the web view allows plug-ins.

Enabling Style Sheets

userStyleSheetEnabled

A Boolean that indicates whether or not user style sheets are enabled in the web view.

Getting and Setting Fonts

cursiveFontFamily

The cursive font family of the web view.

fantasyFontFamily

The fantasy font family of the web view.

fixedFontFamily

The fixed font family of the web view.

sansSerifFontFamily

The sans serif font family of the web view.

serifFontFamily

The serif font family of the web view.

standardFontFamily

The standard font family of the web view.

Getting and Setting Font Sizes

defaultFixedFontSize

The default fixed font size of the web view.

defaultFontSize

The default font size of the web view.

minimumFontSize

The minimum font size of the web view.

minimumLogicalFontSize

The minimum logical font size of the web view.

Getting and Setting Text Encoding

defaultTextEncodingName

The default text encoding of the web view.

Getting and Setting Incremental Rendering

suppressesIncrementalRendering

A Boolean that indicates whether incremental rendering should be suppressed.

Handling Images

allowsAnimatedImageLooping

A Boolean that indicates whether or not the receiver allows animated images to loop.

allowsAnimatedImages

A Boolean that indicates whether or not the receiver allows animated images.

loadsImagesAutomatically

A Boolean that indicates whether or not the web view allows images to be loaded automatically.

Printing Backgrounds

shouldPrintBackgrounds

A Boolean that indicates whether or not the web view should include backgrounds when printing.

Enabling Private Browsing

privateBrowsingEnabled

A Boolean that indicates whether or not private browsing is enabled.

Controlling User Focus

tabsToLinks

A Boolean that indicates whether or not the tab key will focus links.

Caching

usesPageCache

A Boolean that indicates whether the web views associated with the receiver should use the shared page cache.

cacheModel

The cache model for the web views associated with the receiver.

Constants

WebCacheModel

Specifies the caching model for a web view.

Notifications

WebPreferencesChangedNotification

Posted when the web preference settings are changed.

Relationships

Inherits From

Conforms To

See Also

Setting Up a Web View (Legacy)

WebView

WebView is the core view class in the WebKit framework that manages interactions between the WebFrame and WebFrameView classes. To embed web content in your application, you just create a WebView object, attach it to a window, and send a loadRequest: message to its main frame.

Deprecated
WebUIDelegate

Web view user interface delegates implement this protocol to control the opening of new windows, augment the behavior of default menu items displayed when the user clicks elements, and perform other user interface–related tasks. These methods can be invoked as a result of handling JavaScript or other plug-in content. Delegates that display more than one web view per window, for example, need to implement some of these methods to handle that case. The default implementation assumes one window per web view, so non-conventional user interfaces might implement a user interface delegate.

Deprecated