Note: Advice in this article will only work for DotNetBrowser 1.
See the corresponding article for DotNetBrowser 2 here.
DotNetBrowser provides functionality that allows you to enable or disable various features, such as images, JavaScript
, videos, etc., for each Browser
instance. Use the BrowserPreferences
class to work with Browser
features/preferences. To modify some features/preferences you need to obtain BrowserPreferences
instance using the BrowserPreferences
property, modify preferences, and save them by setting the same property.
The following sample code demonstrates how to disable loading images and JavaScript
execution on www.google.com web page:
C#
Browser browser = BrowserFactory.Create(); // Gets the current Browser's preferences BrowserPreferences preferences = browser.Preferences; preferences.ImagesEnabled = false; preferences.JavaScriptEnabled = false; // Updates Browser's preferences browser.Preferences = preferences; // Images and JavaScript will be disabled browser.LoadURL("http://www.google.com/");
VB.NET
Dim browser As Browser = BrowserFactory.Create() ' Gets the current Browser's preferences Dim preferences As BrowserPreferences = browser.Preferences preferences.ImagesEnabled = False preferences.JavaScriptEnabled = False ' Updates Browser's preferences browser.Preferences = preferences ' Images and JavaScript will be disabled browser.LoadURL("http://www.google.com/")