Note: Advice in this article will only work for JxBrowser 6. See the corresponding article for JxBrowser 7 here.(注意:本文中的建议仅适用于JxBrowser6,JxBrowser7相应文章请点击这里。)


JxBrowser provides functionality that allows you to enable or disable various features, such as images, JavaScript, videos, etc., for each Browser instance. Use BrowserPreferences class to work with Browser features/preferences. To modify some features/preferences you must obtain BrowserPreferences instance using the Browser.getPreferences() method, modify preferences, and save them using the Browser.setPreferences() method.(JxBrowser提供的功能使您可以为每个浏览器实例启用或禁用各种功能,例如图像,JavaScript,视频等。使用BrowserPreferences类可使用浏览器功能/首选项。若要修改某些功能/首选项,必须使用Browser.getPreferences()方法获取BrowserPreferences实例,修改首选项后使用Browser.setPreferences()方法保存它们。)


The following sample demonstrates how to disable loading images and JavaScript execution on www.google.com web page: (以下示例演示了如何在www.google.com网页上禁用加载图像和禁用JavaScript:)

Browser browser = new Browser();

// Gets the current Browser's preferences
BrowserPreferences preferences = browser.getPreferences();
preferences.setImagesEnabled(false);
preferences.setJavaScriptEnabled(false);

// Updates Browser's preferences
browser.setPreferences(preferences);

// Images and JavaScript will be disabled
browser.loadURL("http://www.google.com/");