Table of Contents

Interface IBrowser

Namespace
DotNetBrowser.Browser
Assembly
DotNetBrowser.dll

A web browser control that allows loading a web page or a local HTML file, accessing DOM and executing JavaScript on the loaded web page, getting notifications about loading progress, dispatching keyboard and mouse events, etc.

public interface IBrowser : IDisposable, IAutoDisposable
Inherited Members

Remarks

The IBrowser instance itself is running in a separate native process that allocates memory and system resources that must be released. So, when a IBrowser instance is no longer needed, it must be disposed through the Dispose() method to release all the allocated memory and system resources. For example:

IBrowser browser = engine.CreateBrowser();
...
browser.Dispose();

Any attempt to use an already disposed IBrowser instance will lead to the ObjectDisposedException.

The IBrowser instance is disposed automatically when its IEngine is disposed or unexpectedly crashed. If the instance represents a popup window created by JavaScript via the window.open() function, then JavaScript can close the instance using the window.close() function.

To get notifications that the IBrowser instance has been disposed please subscribe to the following event:

browser.Disposed += (s, e) => {
    // The Browser instance has been disposed.
};

Properties

AllFrames

Gets all the frames on the currently loaded web page.

Audio

Gets the IAudio instance that allows controlling audio on the loaded web page and receive notifications when audio has been started or stopped playing.

Capture

Gets the ICapture instance that can be used for listening and handling capture sessions.

Cast

Gets the ICast instance that can be used for casting media on receivers.

ConvertJsNameHandler

Gets or sets a handler that is used for the JavaScript name converting. Implement this handler to have control of how the names are converted when binding or executing JavaScript.

CreatePopupHandler

Gets or sets a handler that is used when the browser decides whether a new popup instance can be created or not.

CreditCards

Gets the ICreditCards instance that can be used for working with credit cards saved in the Chromium credit card store.

DevTools

Gets the IDevTools instance that allows working with Chromium Developer Tools for this browser.

Dialogs

Gets the IDialogs instance that can be used for configuring the dialogs that can be shown by browser.

DragAndDrop

Gets the IDragAndDrop instance that can be used for managing drag&drop operations for the browser.

Engine

Gets the IEngine instance associated with this browser.

Favicon

Gets the favicon of the currently loaded web page.

FocusedFrame

Gets the focused frame on the currently loaded web page.

FullScreen

Gets the IFullScreen instance that can be used for controlling the browser's fullscreen mode.

InjectCssHandler

Gets or sets a handler that is used when the document element has been created and a custom stylesheet can be injected into the document.

InjectJsHandler

Gets or sets a handler that is used when the document element has been created and a custom JavaScript can be injected into the document.

JsDialogs

Gets the IJsDialogs instance that can be used for configuring the JavaScript dialogs that can be shown by browser.

Keyboard

Gets the IKeyboard instance that can be used for listening and simulating keyboard input events.

MainFrame

The main frame on the currently loaded web page, if it exists.

Mouse

Gets the IMouse instance that can be used for listening and simulating mouse input events.

Navigation

Gets the INavigation instance that can be used for controlling navigation in the current browser instance.

OpenExtensionActionPopupHandler

Gets or sets a handler that is used for handling the popups that are requested to be shown by the extension action.

OpenPopupHandler

Gets or sets a handler that is used when a new popup browser instance should be opened.

Passwords

Gets the IPasswords instance that can be used for working with logins and passwords saved in the Chromium password store.

PrintHtmlContentHandler

Gets or sets a handler that is used when the HTML content printing is initiated.

PrintPdfContentHandler

Gets or sets a handler that is used when the PDF content printing is initiated.

Profile

Gets the IProfile instance associated with this browser.

RequestPdfDocumentPasswordHandler

Gets or sets a handler that is used when the frame requests the password for an encrypted PDF document.

RequestPrintHandler

Gets or sets a handler that is used when the printing is initiated.

SelectCertificateHandler

Gets or sets a handler that is used when the web server requires authorization via client certificate.

Settings

Gets the IBrowserSettings instance that can be used for modifying the settings of the browser.

ShowContextMenuHandler

Gets or sets a handler that is used when the browser should show a context menu.

Size

Gets or sets the browser size.

StartDownloadHandler

Gets or sets a handler that is used when the browser is about to start downloading the file.

TextFinder

Gets the ITextFinder instance that can be used for finding text on a web page loaded in the browser.

Title

Gets the title of the currently loaded web page.

Touch

Gets the ITouch instance that can be used for listening touch input events.

Url

Gets the URL of the currently loaded web page or an empty string if the browser hasn't loaded any web page yet.

UserAgent

Gets or sets the user-agent of the current browser instance.

UserDataProfiles

Gets the IUserDataProfiles instance that can be used for working with user data profiles saved in the Chromium user data store.

Zoom

Gets the IZoom instance that can be used for zooming content of a web page loaded in the current browser instance.

Methods

DisposeAsync(BrowserDisposeOptions)

Asynchronously disposes the current browser instance according to the given options.

Focus()

Tells the browser that it has focus and must be activated.

ReplaceMisspelledWord(string)

Replaces misspelled word under cursor on the currently loaded web page with the given word. If there is no misspelled word under cursor, this method does nothing.

SaveWebPage(string, string, SavePageType)

Initiates the saving process of the currently loaded web page. The web page can be saved as a single HTML file or the file with resources. Before saving a web page make sure that it is not being loaded. It is recommended to completely loaded the web page and only then save it.

SetPrivateKeyProviderPin(CspParameters)

Sets the key exchange PIN for the particular cryptographic service provider (CSP) and the particular key container in it. This functionality can be used to set the PIN that is requested when trying to use a client certificate stored on the smart card.

TakeImage()

Creates and returns an image of the currently loaded web page.

Unfocus()

Tells the browser that it does not have focus and must be deactivated.

Events

BrowserBecameResponsive

Occurs when the browser instance has become responsive.

BrowserBecameUnresponsive

Occurs when the browser instance has become unresponsive.

ConsoleMessageReceived

Occurs when the message was added to the console.

FaviconChanged

Occurs when the web page favicon has changed.

FocusGained

Occurs when the browser instance has gained the focus.

FocusLost

Occurs when the browser instance has lost the focus.

FocusRequested

Occurs when JavaScript sends a request to focus the Browser instance by calling the window.focus() method.

FrameCreated

Occurs when the IFrame has been created.

FrameDeleted

Occurs when the IFrame has been deleted.

MediaStreamCaptureStarted

Occurs when the web page has started capturing an audio or video stream.

MediaStreamCaptureStopped

Occurs when the web page has stopped capturing an audio or video stream.

PrintPreviewClosed

Occurs when print preview dialog is closed.

PrintPreviewOpened

Occurs when print preview dialog is opened.

RenderProcessTerminated

Occurs when a render process has been terminated.

SpellCheckCompleted

Occurs when spell checking on the frame has been completed.

StatusChanged

Occurs when the status text has been changed.

TitleChanged

Occurs when the web page title has been changed.

UpdateBoundsRequested

Occurs when JavaScript requests to update bounds of the Browser instance.