WebView.SetPreferences
----------------------

Sets WebView preferences parameters.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [WebView](component_WebView.md) | [2.2](newinversion22.md) | ✅ Yes | ✅ Yes | ❌ No | ❌ No | ✅ Yes |

MBS( "WebView.SetPreferences"; WebViewerRef; ParameterName { ; ParameterValue } ) 

**MBS**( **"WebView.SetPreferences";** /\* Sets WebView preferences parameters. \*/  
**$WebViewerRef**; /\* Either the Web Viewer Object Name or the Web Viewer ID as returned by "[WebView.FindByName](WebViewFindByName.md)" function.e.g. "web" \*/   
**$ParameterName**; /\* The name of the parameter.e.g. isJavaEnabled \*/   
**$ParameterValue**) /\* Optional; The value for the given parameter: A boolean value for allowsAnimatedImageLooping, allowsAnimatedImages, javaEnabled, javaScriptCanOpenWindowsAutomatically, javaScriptEnabled, loadsImagesAutomatically, plugInsEnabled, privateBrowsingEnabled, shouldPrintBackgrounds, tabsToLinks, userStyleSheetEnabled and usesPageCache. A number for cacheModel, defaultFixedFontSize, defaultFontSize, minimumFontSize or minimumLogicalFontSize. A string for cursiveFontFamily, defaultTextEncodingName, fantasyFontFamily, fixedFontFamily, sansSerifFontFamily, serifFontFamily or standardFontFamily.e.g. 0 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| WebViewerRef | Either the Web Viewer Object Name or the Web Viewer ID as returned by "[WebView.FindByName](WebViewFindByName.md)" function. | "web" |  |
| ParameterName | The name of the parameter. | isJavaEnabled |  |
| ParameterValue | The value for the given parameter: A boolean value for allowsAnimatedImageLooping, allowsAnimatedImages, javaEnabled, javaScriptCanOpenWindowsAutomatically, javaScriptEnabled, loadsImagesAutomatically, plugInsEnabled, privateBrowsingEnabled, shouldPrintBackgrounds, tabsToLinks, userStyleSheetEnabled and usesPageCache. A number for cacheModel, defaultFixedFontSize, defaultFontSize, minimumFontSize or minimumLogicalFontSize. A string for cursiveFontFamily, defaultTextEncodingName, fantasyFontFamily, fixedFontFamily, sansSerifFontFamily, serifFontFamily or standardFontFamily. | 0 | Optional |

### Result

Returns OK or an error message.

### Description

Sets WebView preferences parameters.  
For WebKit 1.x you can pass empty WebViewerRef to access global preferences.  
  
Available keys for WebKit 1.x (FileMaker till version 15 and [WebView.Create](WebViewCreate.md)): allowsAnimatedImageLooping, allowsAnimatedImages, cacheModel, cursiveFontFamily, defaultFixedFontSize, defaultFontSize, defaultTextEncodingName, fantasyFontFamily, fixedFontFamily, javaEnabled, javaScriptCanOpenWindowsAutomatically, javaScriptEnabled, loadsImagesAutomatically, minimumFontSize, minimumLogicalFontSize, plugInsEnabled, privateBrowsingEnabled, sansSerifFontFamily, serifFontFamily, shouldPrintBackgrounds, standardFontFamily, tabsToLinks, userStyleSheetEnabled or usesPageCache.  
  
Available keys for WebKit 2.x (FileMaker 16): shouldPrintBackgrounds, developerExtrasEnabled, logsPageMessagesToSystemConsoleEnabled, minimumFontSize, javaScriptEnabled, javaScriptCanOpenWindowsAutomatically, telephoneNumberDetectionIsEnabled, javaEnabled and plugInsEnabled.  
  
New in version 10.2: mediaDevicesEnabled and mediaStreamEnabled to allow camera/microphone/screen access.  
New in version 10.3: CrossOriginResourcePolicyEnabled and webSecurityEnabled to enable cross site scripting.  
  
Please check WebKit documentation for details.  
  
Implemented for Windows with Microsoft Edge/Chrome engine (WebView2) in MBS Plugin 11.5 when using FileMaker Pro 19.4 or newer.   
Possible keys: IsScriptEnabled, IsWebMessageEnabled, AreDefaultScriptDialogsEnabled, IsStatusBarEnabled, AreDevToolsEnabled, AreDefaultContextMenusEnabled, AreHostObjectsAllowed, IsZoomControlEnabled, IsBuiltInErrorPageEnabled, areBrowserAcceleratorKeysEnabled, IsPinchZoomEnabled, IsPasswordAutosaveEnabled and IsGeneralAutofillEnabled.  
  
MBS Plugin 11.5 adds fraudulentWebsiteWarningEnabled for macOS 10.15 and iOS 13.0 to set whether the warnings or fraudulent websites is enabled. The textInteractionEnabled setting in macOS 12.0 and iOS 15.0 allows to set whether text interactions are enabled.  
  
Added IsSwipeNavigationEnabled and HiddenPdfToolbarItems options in version 14.2 for Windows using WebView 2. If used with a touch display, the IsSwipeNavigationEnabled option can disable swiping since it is on by default. HiddenPdfToolbarItems allows you to disable toolbar items for when PDF documents show. Combine the following values to disable some toolbar items:  
  
| Bookmarks | 256 | The contents button on PDF toolbar. |
|---|--:|---|
| FitPage | 64 | The fit to width button on PDF toolbar. |
| FullScreen | 2048 | The full screen button on PDF toolbar. |
| MoreSettings | 4096 | The setting and more button on PDF toolbar. |
| None | 0 | No item. By default the HiddenPdfToolbarItems equal to this value. |
| PageLayout | 128 | The page view button on PDF toolbar. |
| PageSelector | 512 | The page number button on PDF toolbar. |
| Print | 2 | The print button on PDF toolbar. |
| Rotate | 32 | The rotate button on PDF toolbar. |
| Save | 1 | The save button on PDF toolbar. |
| SaveAs | 4 | The save as button on PDF toolbar. |
| Search | 1024 | The search button on PDF toolbar. |
| ZoomIn | 8 | The zoom in button on PDF toolbar. |
| ZoomOut | 16 | The zoom out button on PDF toolbar. |

### Examples

set print background option:

 MBS ("WebView.SetPreferences"; $WebViewerRef ; "shouldPrintBackgrounds", 1)  
Disables image loading:

 MBS ("WebView.SetPreferences"; $WebViewerRef ; "loadsImagesAutomatically", 0)  
Disable Java:

 MBS ("WebView.SetPreferences"; $WebViewerRef ; "javaEnabled"; 0)  
Disable Plugins:

 MBS ("WebView.SetPreferences"; $WebViewerRef ; "plugInsEnabled"; 0)  
Set developer extras enabled state for WebViewer to show inspector:

 Set Variable \[$r ; Value: MBS ("Webview.SetPreferences"; "web"; "developerExtrasEnabled"; 1) \]  
Enable file URLs:

 Set Variable \[$r ; Value:MBS ("Webview.SetPreferences"; "web"; "allowFileAccessFromFileURLs"; 1)\]  
Disable web security:

 MBS ( "WebView.SetPreferences"; "web"; "webSecurityEnabled"; 0 )  
Disable cross origin resource policy enabled:

 MBS ( "WebView.SetPreferences"; "web"; "CrossOriginResourcePolicyEnabled"; 0)  
Enable console messages to Console.app:

 Set Variable \[ $r ; Value: MBS ( "WebView.SetPreferences"; "web"; "logsPageMessagesToSystemConsoleEnabled"; 1 ) \]  
Disable JavaScript:

 MBS ("WebView.SetPreferences"; $WebViewerRef ; "javaScriptEnabled"; 0)  
### See also

- [WebView.Create](WebViewCreate.md)
- [WebView.FindByName](WebViewFindByName.md)
- [WebView.GetPreferences](WebViewGetPreferences.md)
- [WebView.InstallUserMediaAccess](WebViewInstallUserMediaAccess.md)
- [WebView.PrintToFile](WebViewPrintToFile.md)
- [WebView.RenderImage](WebViewRenderImage.md)
- [WebView.RenderPDF](WebViewRenderPDF.md)
- [WebView.ShowDevTools](WebViewShowDevTools.md)

### Release notes

- **Version 14.2**
    - Added IsSwipeNavigationEnabled and HiddenPdfToolbarItems as options to [WebView.SetPreferences](https://www.mbsplugins.eu/WebViewSetPreferences.shtml) and [WebView.GetPreferences](https://www.mbsplugins.eu/WebViewGetPreferences.shtml) for Windows.
- **Version 13.1**
    - Added shouldPrintBackgrounds to [WebView.SetPreferences](https://www.mbsplugins.eu/WebViewSetPreferences.shtml) and [WebView.GetPreferences](https://www.mbsplugins.eu/WebViewGetPreferences.shtml) for WebKit 2 to control printing of backgrounds.
- **Version 11.5**
    - Added fraudulentWebsiteWarningEnabled and textInteractionEnabled settings for [WebView.GetPreferences](https://www.mbsplugins.eu/WebViewGetPreferences.shtml) and [WebView.SetPreferences](https://www.mbsplugins.eu/WebViewSetPreferences.shtml) functions.
- **Version 10.3**
    - Added webSecurityEnabled and CrossOriginResourcePolicyEnabled keys for [WebView.SetPreferences](https://www.mbsplugins.eu/WebViewSetPreferences.shtml) function.
- **Version 10.2**
    - Added new preferences keys for [WebView.SetPreferences](https://www.mbsplugins.eu/WebViewSetPreferences.shtml): mediaDevicesEnabled and mediaStreamEnabled.
- **Version 8.0**
    - Added allowUniversalAccessFromFileURLs parameter for [WebView.SetPreferences](http://www.mbsplugins.eu/WebViewSetPreferences.shtml).

### Example Databases

- [WebViewer/InstallUserMediaAccess](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/WebViewer/InstallUserMediaAccess.shtml#2ScriptAnchor_)
- [WebViewer/Web Preferences (Mac)](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/WebViewer/Web%20Preferences%20%28Mac%29.shtml#1GroupButton24.000000011.000000043.0000000110.0000000LayoutObjectAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 14.2pr3](https://www.mbsplugins.de/archive/2024-04-16/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [Printing a WebViewer in FileMaker](https://www.mbsplugins.de/archive/2024-02-16/Printing_a_WebViewer_in_FileMa/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 13.1pr1](https://www.mbsplugins.de/archive/2023-02-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [New in version 11.5 of MBS FileMaker Plugin](https://www.mbsplugins.de/archive/2021-11-30/New_in_version_115_of_MBS_File/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 11.5](https://www.mbsplugins.de/archive/2021-11-16/MBS_FileMaker_Plugin_115/monkeybreadsoftware_blog_filemaker)
- [WebPreferences for WebView2](https://www.mbsplugins.de/archive/2021-11-05/WebPreferences_for_WebView2/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 11.5pr4](https://www.mbsplugins.de/archive/2021-10-27/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [WebViewer preferences](https://www.mbsplugins.de/archive/2021-01-21/WebViewer_preferences/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 10.3pr1](https://www.mbsplugins.de/archive/2020-06-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [Automate web viewer in FileMaker](https://www.mbsplugins.de/archive/2020-01-20/Automate_web_viewer_in_FileMak/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 3/2024, Seite 32](https://filemaker-magazin.de/neuigkeit/4263-Appetithappen-FMM_202403)

This function checks for a license.

Created 18th August 2014 , last changed 11st April 2024

  
[WebView.SetPageSizeMultiplier](WebViewSetPageSizeMultiplier.md) - [WebView.SetPrintParameter](WebViewSetPrintParameter.md)

[HTML Version](WebViewSetPreferences.shtml)