Setting WebView Options

EO.WebBrowser supports a number of per WebView options, such as disabling JavaScript, custom CSS styles, etc. All options are exposed through WebViewOptions object. These options can be set on application level, engine level or on each WebView individually.

Setting Options on the Application Level

The following code demonstrates how to disable JavaScript and image loading on application level:

//Disable JavaScript and image loading for all
//WebView instances created after this call
EO.WebEngine.WebViewOptions options = new EO.WebEngine.WebViewOptions();
options.AllowJavaScript = false;
options.LoadImages = false;
EO.WebEngine.EngineOptions.Default.SetDefaultWebViewOptions(options);

The code must be called before any WebView is created.

Setting Options on the Engine Level

The following code demonstrates how to disable JavaScript and image loading for a single Engine:

//Disable JavaScript and image loading for a specific Engine
EO.WebEngine.WebViewOptions options = new EO.WebEngine.WebViewOptions();
options.AllowJavaScript = false;
options.LoadImages = false;
engine1.Options.SetDefaultWebViewOptions(options);

The code must be called before the engine starts. See here for more information on how to manage engines.

Setting Options on a Single WebView

The following code demonstrates how to disable JavaScript and image loading for a single WebView:

//Disable JavaScript and image loading for the WebView
EO.WebEngine.WebViewOptions options = new EO.WebEngine.WebViewOptions();
options.AllowJavaScript = false;
options.LoadImages = false;
WebView1.SetOptions(options);

Note that the code must be called before the WebView has been created.