Mac Developer Library

Developer

WebKit Framework Reference WebPreferences Class Reference

Options
Deployment Target:

On This Page
Language:

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 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. More...

Inheritance


Conforms To


Import Statement


import WebKit @import WebKit;

Availability


Available in OS X v10.2 and later.
  • Returns the standard set of preferences that may be used by all WebView objects.

    Declaration

    Swift

    class func standardPreferences() -> WebPreferences!

    Objective-C

    + (WebPreferences *)standardPreferences

    Return Value

    A WebPreferences object containing the standard set of preferences that may be used by all WebView objects.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

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

    Declaration

    Swift

    init!(identifier anIdentifier: String!)

    Objective-C

    - (instancetype)initWithIdentifier:(NSString *)anIdentifier

    Parameters

    anIdentifier

    A unique identifier for the WebPreferences object

    Return Value

    A newly initialized WebPreferences object with the identifier; if an existing WebPreferences object with that identifier exists, it is returned instead.

    Discussion

    The anIdentifier argument should be unique—it is prepended to the keys used to store the receiver’s attributes in the user defaults database. WebView objects can share a WebPreferences object 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.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

    See Also

    – identifier

  • Returns the receiver’s identifier.

    Declaration

    Swift

    var identifier: String! { get }

    Objective-C

    @property(nonatomic, readonly, copy) NSString *identifier

    Return Value

    The identifier of the WebPreferences object.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

  • Returns whether or not the receiver’s attributes are automatically stored in the user defaults database.

    Declaration

    Swift

    var autosaves: Bool

    Objective-C

    @property(nonatomic) BOOL autosaves

    Return Value

    YEStrue if the receiver’s attributes are automatically stored, NOfalse otherwise.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

  • Sets whether or not the receiver’s attributes are stored in the user defaults database.

    Declaration

    Swift

    var autosaves: Bool

    Objective-C

    @property(nonatomic) BOOL autosaves

    Parameters

    flag

    Set to YEStrue if the receiver’s attributes should be automatically stored in the user defaults database, NOfalse otherwise.

    Discussion

    The default value is NOfalse.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

    See Also

    – autosaves

  • Sets whether or not the web view allows Java.

    Declaration

    Swift

    var javaEnabled: Bool

    Objective-C

    @property(nonatomic, getter=isJavaEnabled) BOOL javaEnabled

    Parameters

    flag

    Set to YEStrue to indicate that the web view allows Java, otherwise NOfalse.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

  • isJavaEnabled isJavaEnabled Available in OS X v10.2 through OS X v10.9

    Returns whether or not Java is enabled for the web view.

    Declaration

    Objective-C

    - (BOOL)isJavaEnabled

    Return Value

    YEStrue if the view allows Java, NOfalse otherwise.

    Import Statement

    Availability

    Available in OS X v10.2 through OS X v10.9.

  • Sets whether or not the web view allows JavaScript.

    Declaration

    Swift

    var javaScriptEnabled: Bool

    Objective-C

    @property(nonatomic, getter=isJavaScriptEnabled) BOOL javaScriptEnabled

    Parameters

    flag

    Set to YEStrue if the web view should allow JavaScript, otherwise NOfalse.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

  • isJavaScriptEnabled isJavaScriptEnabled Available in OS X v10.2 through OS X v10.9

    Returns whether or not JavaScript is enabled for the web view.

    Declaration

    Objective-C

    - (BOOL)isJavaScriptEnabled

    Return Value

    YEStrue if the web view allows JavaScript, otherwise NOfalse.

    Import Statement

    Availability

    Available in OS X v10.2 through OS X v10.9.

  • Sets whether or not the web view allows JavaScript to open windows automatically.

    Declaration

    Swift

    var javaScriptCanOpenWindowsAutomatically: Bool

    Objective-C

    @property(nonatomic) BOOL javaScriptCanOpenWindowsAutomatically

    Parameters

    flag

    Set to YEStrue if the web view should allow JavaScript to open windows automatically, otherwise NOfalse.

    Discussion

    Explicit calls to a JavaScript window opener that are activated by user action (such as a button click) are not affected by this setting.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

  • Returns whether or not JavaScript can open windows automatically for the web view.

    Declaration

    Swift

    var javaScriptCanOpenWindowsAutomatically: Bool

    Objective-C

    @property(nonatomic) BOOL javaScriptCanOpenWindowsAutomatically

    Return Value

    YEStrue if the web view allows JavaScript to open windows automatically, otherwise NOfalse.

    Discussion

    Explicit calls to a JavaScript window opener that are activated by user action (such as a button click) are not affected by this setting.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

  • Sets whether or not the web view allows plug-ins.

    Declaration

    Swift

    var plugInsEnabled: Bool

    Objective-C

    @property(nonatomic, getter=arePlugInsEnabled) BOOL plugInsEnabled

    Parameters

    flag

    Set to YEStrue if the web view should allow plug-ins, otherwise NOfalse.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

  • arePlugInsEnabled arePlugInsEnabled Available in OS X v10.2 through OS X v10.9

    Returns whether or not the web view allows plug-ins.

    Declaration

    Objective-C

    - (BOOL)arePlugInsEnabled

    Return Value

    YEStrue if the web view allows plug-ins, otherwise NOfalse.

    Import Statement

    Availability

    Available in OS X v10.2 through OS X v10.9.

  • Sets whether or not user style sheets are enabled in the web view.

    Declaration

    Swift

    var userStyleSheetEnabled: Bool

    Objective-C

    @property(nonatomic) BOOL userStyleSheetEnabled

    Parameters

    flag

    Set to YEStrue if the user style sheets should be enabled in the web view, otherwise NOfalse.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

  • Returns whether user style sheets are enabled in the web view.

    Declaration

    Swift

    var userStyleSheetEnabled: Bool

    Objective-C

    @property(nonatomic) BOOL userStyleSheetEnabled

    Return Value

    YEStrue if the user style sheets are enabled in the web view, otherwise NOfalse.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

  • Sets the location of the user style sheet.

    Declaration

    Swift

    var userStyleSheetLocation: NSURL!

    Objective-C

    @property(nonatomic, strong) NSURL *userStyleSheetLocation

    Parameters

    URL

    An NSURL object containing the location of the user style sheet.

    Discussion

    The user style sheet will override all existing CSS definitions on the page. setUserStyleSheetEnabled: must have already been set to YEStrue for this method to have an effect.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

  • Returns the location of the user style sheet.

    Declaration

    Swift

    var userStyleSheetLocation: NSURL!

    Objective-C

    @property(nonatomic, strong) NSURL *userStyleSheetLocation

    Return Value

    An NSURL object containing the location of the user style sheet.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

  • Sets the cursive font family of the web view.

    Declaration

    Swift

    var cursiveFontFamily: String!

    Objective-C

    @property(nonatomic, copy) NSString *cursiveFontFamily

    Parameters

    family

    The font family to use as the default font for cursive text.

    Discussion

    This preference affects text whose properties indicate that it should be displayed in a cursive font but do not specify a particular font.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

  • Returns the cursive font family for the web view.

    Declaration

    Swift

    var cursiveFontFamily: String!

    Objective-C

    @property(nonatomic, copy) NSString *cursiveFontFamily

    Return Value

    The default font used for cursive text.

    Discussion

    This preference affects text whose properties indicate that it should be displayed in a cursive font but do not specify a particular font.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

  • Sets the fantasy font family of the web view.

    Declaration

    Swift

    var fantasyFontFamily: String!

    Objective-C

    @property(nonatomic, copy) NSString *fantasyFontFamily

    Parameters

    family

    The font family to use as the default for content marked with a fantasy font.

    Discussion

    This preference affects text whose properties indicate that it should be displayed in a fantasy font but do not specify a particular font.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

  • Returns the fantasy font family for the web view.

    Declaration

    Swift

    var fantasyFontFamily: String!

    Objective-C

    @property(nonatomic, copy) NSString *fantasyFontFamily

    Return Value

    The font family used as the default for content marked with a fantasy font.

    Discussion

    This preference affects text whose properties indicate that it should be displayed in a fantasy font but do not specify a particular font.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

  • Sets the fixed font family of the web view.

    Declaration

    Swift

    var fixedFontFamily: String!

    Objective-C

    @property(nonatomic, copy) NSString *fixedFontFamily

    Parameters

    family

    The font family to use as the default for content marked with a fixed font.

    Discussion

    This preference affects text whose properties indicate that it should be displayed in a fixed font but do not specify a particular font.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

  • Returns the fixed font family for the web view.

    Declaration

    Swift

    var fixedFontFamily: String!

    Objective-C

    @property(nonatomic, copy) NSString *fixedFontFamily

    Return Value

    The font family used as the default for content marked with a fixed font.

    Discussion

    This preference affects text whose properties indicate that it should be displayed in a fixed font but do not specify a particular font.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

  • Sets the sans serif font family of the web view.

    Declaration

    Swift

    var sansSerifFontFamily: String!

    Objective-C

    @property(nonatomic, copy) NSString *sansSerifFontFamily

    Parameters

    family

    The font family to use as the default for content marked with a sans-serif font.

    Discussion

    This preference affects text whose properties indicate that it should be displayed in a sans-serif font but do not specify a particular font.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

  • Returns the sans serif font family for the web view.

    Declaration

    Swift

    var sansSerifFontFamily: String!

    Objective-C

    @property(nonatomic, copy) NSString *sansSerifFontFamily

    Return Value

    The font family used as the default for content marked with a sans-serif font.

    Discussion

    This preference affects text whose properties indicate that it should be displayed in a sans-serif font but do not specify a particular font.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

  • Sets the serif font family of the web view.

    Declaration

    Swift

    var serifFontFamily: String!

    Objective-C

    @property(nonatomic, copy) NSString *serifFontFamily

    Parameters

    family

    The font family to use as the default for content marked with a serif font.

    Discussion

    This preference affects text whose properties indicate that it should be displayed in a serif font but do not specify a particular font.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

  • Returns the serif font family for the web view.

    Declaration

    Swift

    var serifFontFamily: String!

    Objective-C

    @property(nonatomic, copy) NSString *serifFontFamily

    Return Value

    The font family used as the default for content marked with a serif font.

    Discussion

    This preference affects text whose properties indicate that it should be displayed in a serif font but do not specify a particular font.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

  • Sets the standard font family of the web view.

    Declaration

    Swift

    var standardFontFamily: String!

    Objective-C

    @property(nonatomic, copy) NSString *standardFontFamily

    Parameters

    family

    The font family to use as the default for content that does not specify a font.

    Discussion

    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).

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

  • Returns the standard font family used by the web view.

    Declaration

    Swift

    var standardFontFamily: String!

    Objective-C

    @property(nonatomic, copy) NSString *standardFontFamily

    Return Value

    The font family used as the default for content that does not specify a font.

    Discussion

    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).

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

  • Sets the default fixed font size of the web view.

    Declaration

    Swift

    var defaultFixedFontSize: Int32

    Objective-C

    @property(nonatomic) int defaultFixedFontSize

    Parameters

    size

    The default font size to use for content displayed in a fixed font if no font size is specified.

    Discussion

    The font size specified by size should always be greater than zero.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

  • Returns the default fixed font size for the web view.

    Declaration

    Swift

    var defaultFixedFontSize: Int32

    Objective-C

    @property(nonatomic) int defaultFixedFontSize

    Return Value

    The default font size used for content displayed in a fixed font if no font size is specified.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

  • Sets the default font size of the web view.

    Declaration

    Swift

    var defaultFontSize: Int32

    Objective-C

    @property(nonatomic) int defaultFontSize

    Parameters

    size

    The default font size to use for content displayed in a fixed font if no font size or font family is specified.

    Discussion

    The font size specified by size should always be greater than zero.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

  • Returns the default font size for the web view.

    Declaration

    Swift

    var defaultFontSize: Int32

    Objective-C

    @property(nonatomic) int defaultFontSize

    Return Value

    The default font size used for content displayed in a fixed font if no font size or font family is specified.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

  • Sets the minimum font size of the web view.

    Declaration

    Swift

    var minimumFontSize: Int32

    Objective-C

    @property(nonatomic) int minimumFontSize

    Parameters

    size

    The minimum font size to use for content regardless of the font size specified by that content.

    Discussion

    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.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

  • Returns the minimum font size for the web view.

    Declaration

    Swift

    var minimumFontSize: Int32

    Objective-C

    @property(nonatomic) int minimumFontSize

    Return Value

    The minimum font size that will be used for content regardless of the font size specified by that content.

    Discussion

    The default value is 1, meaning that the minimum font size is constrained only by the minimum logical font size.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

  • Sets the minimum logical font size of the web view.

    Declaration

    Swift

    var minimumLogicalFontSize: Int32

    Objective-C

    @property(nonatomic) int minimumLogicalFontSize

    Parameters

    size

    The minimum logical font size that the web view should use.

    Discussion

    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.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.3 and later.

  • Returns the minimum logical font size for the web view.

    Declaration

    Swift

    var minimumLogicalFontSize: Int32

    Objective-C

    @property(nonatomic) int minimumLogicalFontSize

    Return Value

    The minimum logical font size used by the web view.

    Discussion

    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.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.3 and later.

  • Sets the default text encoding of the web view.

    Declaration

    Swift

    var defaultTextEncodingName: String!

    Objective-C

    @property(nonatomic, copy) NSString *defaultTextEncodingName

    Parameters

    encoding

    The default text encoding to use when interpreting content whose encoding is not specified.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

  • Returns the default text encoding for the web view.

    Declaration

    Swift

    var defaultTextEncodingName: String!

    Objective-C

    @property(nonatomic, copy) NSString *defaultTextEncodingName

    Return Value

    The default text encoding used when interpreting content whose encoding is not specified.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.2 and later.

  • Sets whether incremental rendering should be suppressed.

    Declaration

    Swift

    var suppressesIncrementalRendering: Bool

    Objective-C

    @property(nonatomic) BOOL suppressesIncrementalRendering

    Parameters

    suppressesIncrementalRendering

    Pass YEStrue to suppress incremental rendering, or NOfalse otherwise.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.8 and later.

  • Returns whether incremental rendering is suppressed.

    Declaration

    Swift

    var suppressesIncrementalRendering: Bool

    Objective-C

    @property(nonatomic) BOOL suppressesIncrementalRendering

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.8 and later.

  • Sets whether or not the web view should include backgrounds when printing.

    Declaration

    Swift

    var shouldPrintBackgrounds: Bool

    Objective-C

    @property(nonatomic) BOOL shouldPrintBackgrounds

    Parameters

    flag

    Set to YEStrue if the web view should print backgrounds, otherwise NOfalse.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.3 and later.

  • Returns whether the web view should include backgrounds when printing.

    Declaration

    Swift

    var shouldPrintBackgrounds: Bool

    Objective-C

    @property(nonatomic) BOOL shouldPrintBackgrounds

    Return Value

    YEStrue if the web view prints backgrounds, otherwise NOfalse.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.3 and later.

  • Returns whether or not private browsing is enabled.

    Declaration

    Swift

    var privateBrowsingEnabled: Bool

    Objective-C

    @property(nonatomic) BOOL privateBrowsingEnabled

    Return Value

    YEStrue if private browsing is enabled, otherwise NOfalse.

    Discussion

    Private browsing prevents the web view from maintaining any history, cache, or AutoFill information for the pages being visited.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.3 and later.

  • Sets whether or not private browsing is enabled.

    Declaration

    Swift

    var privateBrowsingEnabled: Bool

    Objective-C

    @property(nonatomic) BOOL privateBrowsingEnabled

    Return Value

    YEStrue if private browsing should be enabled, otherwise NOfalse.

    Discussion

    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.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.3 and later.

  • Returns whether or not the tab key will focus links.

    Declaration

    Swift

    var tabsToLinks: Bool

    Objective-C

    @property(nonatomic) BOOL tabsToLinks

    Return Value

    YEStrue if the user should be able to navigate to links by pressing the tab key, NOfalse otherwise.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.3 and later.

  • Sets whether or not the web view will focus control on links when tabbing.

    Declaration

    Swift

    var tabsToLinks: Bool

    Objective-C

    @property(nonatomic) BOOL tabsToLinks

    Return Value

    YEStrue if the user is able to navigate to links by pressing the tab key, NOfalse otherwise.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.3 and later.

    See Also

    – tabsToLinks

  • Sets whether the web views associated with the receiver should use the shared page cache.

    Declaration

    Swift

    var usesPageCache: Bool

    Objective-C

    @property(nonatomic) BOOL usesPageCache

    Parameters

    usesPageCache

    YEStrue if the web views should use a page cache; otherwise, NOfalse.

    Discussion

    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.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.5 and later.

  • Returns whether the web views associated with the receiver should use the shared page cache.

    Declaration

    Swift

    var usesPageCache: Bool

    Objective-C

    @property(nonatomic) BOOL usesPageCache

    Return Value

    YEStrue if the web views should use a page cache; otherwise, NOfalse.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.5 and later.

  • Sets the cache model for the web views associated with the receiver.

    Declaration

    Swift

    var cacheModel: WebCacheModel

    Objective-C

    @property(nonatomic) WebCacheModel cacheModel

    Parameters

    cacheModel

    The cache model for the web views associated with the receiver. Possible values are described in WebCacheModel.

    Discussion

    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.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.5 and later.

    See Also

    – cacheModel

  • Returns the cache model for a web view.

    Declaration

    Swift

    var cacheModel: WebCacheModel

    Objective-C

    @property(nonatomic) WebCacheModel cacheModel

    Return Value

    The cache model for the web views associated with the receiver. Possible values are described in WebCacheModel.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.5 and later.

Data Types

  • Specifies the caching model for a web view.

    Declaration

    Swift

    enum WebCacheModel : UInt { case DocumentViewer case DocumentBrowser case PrimaryWebBrowser }

    Objective-C

    enum { WebCacheModelDocumentViewer = 0, WebCacheModelDocumentBrowser = 1, WebCacheModelPrimaryWebBrowser = 2 }; typedef NSUInteger WebCacheModel;

    Constants

    • DocumentViewer

      WebCacheModelDocumentViewer

      Releases 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 OS X v10.5 and later.

    • DocumentBrowser

      WebCacheModelDocumentBrowser

      Caches 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 OS X v10.5 and later.

    • PrimaryWebBrowser

      WebCacheModelPrimaryWebBrowser

      Caches 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 OS X v10.5 and later.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.5 and later.