WebBrowserSet

Description

Configures the settings for the WebBrowser control.

Note that some settings must be set before the WebBrowser control is initialized. You can set them in the application Open event.

Syntax

WebBrowserSet (string n, string v)

Argument

Description

n

The name of the setting. The setting can be:

  • CachePath -- The folder that stores the web page cache, cookies etc. You can specify a directory or use the default directory which uses the system environment %HOMEPATH% and %TEMP%, for example, C:\Users\appeon\AppData\Local\Temp\pbcefcache.

    CachePath must be set before the WebBrowser control is initialized. It must be an absolute path, and cannot be a relative path. You can set it in the application Open event.

  • UserDataPath -- The folder that stores the user data dictionary. You can specify a directory or use the default directory which uses the system environment %HOMEPATH% and %TEMP%, for example, C:\Users\appeon\AppData\Local\pbcef\User Data\Dictionaries.

    UserDataPath must be set before the WebBrowser control is initialized. It must be an absolute path, and cannot be a relative path. You can set it in the application Open event.

  • DownloadPath -- The folder that stores the downloaded files etc. You can specify a directory or use the default directory which uses the system environment %HOMEPATH% and %TEMP%, for example, C:\Users\appeon\AppData\Local\Temp\pbcefdownload.

    DownloadPath must be set before the WebBrowser control starts downloading files. It must be an absolute path, and cannot be a relative path.

  • UserAgent -- The User-Agent request header that contains a characteristic string that allows the network protocol peers to identify the application type, operating system, software vendor or software version of the requesting software user agent.

    UserAgent must be set before the WebBrowser control is initialized. You can set it in the application Open event.

  • ProxyAuto -- Whether to use auto proxy detection. The value could be 1 or 0 (the default). Auto proxy detection is used if it is set to 1.

  • ProxyPacUrl -- The URL address of the PAC file. It is unsupported to load the PAC file on the local directory via file:/// (you will have to put the file on the server and load it via http or https).

  • ProxyAddress -- The address of the proxy server.

  • ProxyPort -- The port of the proxy server. The default value is -1.

  • ProxyUser -- The user name that will be authenticated by the proxy server.

  • ProxyPassword -- The password that will be authenticated by the proxy server.

    WebBrowser supports auto proxy detection, PAC (proxy auto configuration) file setting, and manual proxy settings. The priority order of the settings is: auto proxy detection > PAC file setting > manual proxy settings. By default the IE proxy is used.

    If the proxy setting is set before the WebBrowser control is initialized, it will be effective to all Web pages loaded; if it is set before the Navigate operation, then it will be effective to only the Web page being navigated.

  • allow-file-access-from-files -- Whether to allow access to the local files (XML etc.). The value is "true" or "false" (the default).

    This setting must be set before the WebBrowser control is initialized. You can set it in the application Open event.

  • enable-media-stream -- Whether to allow access to the microphone or camera. The value is "true" or "false" (the default).

    This setting must be set before the WebBrowser control is initialized. You can set it in the application Open event.

  • remote-debugging-port -- Whether to enable remote debugging over HTTP on the specified port.

    This setting must be set before the WebBrowser control is initialized. You can set it in the application Open event.

    To support the remote debugging:

    1. Enable remote debugging on the specified port number, by executing the following script in the application Open event:

    li_return = WebBrowserSet("remote-debugging-port", "8210")

    Every time when this script is executed, a page ID is generated. You can get and use this ID through the debugging APIs.

    2. Run the debugging APIs in Chrome or Edge browser. For example:

    Access the main page: http://localhost:8210

    Get the JSON string (which includes the page ID): http://localhost:8210/json

    Get the version information: http://localhost:8210/json/version

    Activate the page: http://localhost:8210/json/activate/{id}, for example, http://localhost:8210/json/activate/054A6021CB9DD4EDBDBFA55E4384EA38

    Close the page: http://localhost:8210/json/close/{id}

    Remote control: http://localhost:8210/devtools/inspector.html?ws=localhost:8210/devtools/page/{id}

    Suppose the current URL is www.appeon.com, here are a few samples of the returned information of the debugging APIs:




v

The value of the setting to be set.


Return value

Integer.

Returns the following error code:

  • 1 -- Success

  • -7 -- CEF has been initialized, and the current item can only be set before CEF initialization.

  • -8 -- The setting name does not exist.

  • -9 -- The path is invalid or does not exist.

Examples

The following example configures the proxy settings for the WebBrowser control in the application Open event.

WebBrowserSet ("ProxyAddress", "192.168.5.16")
WebBrowserSet ("ProxyPort", "8080")
WebBrowserSet ("ProxyUser", "Admin")
WebBrowserSet ("ProxyPassword", "123Test")

See also

WebBrowserGet