Table of Contents

Class BrowsingContext

Namespace
AngleSharp
Assembly
AngleSharp.dll

A simple and lightweight browsing context.

public sealed class BrowsingContext : EventTarget, IBrowsingContext, IEventTarget, IDisposable
Inheritance
BrowsingContext
Implements
Inherited Members
Extension Methods

Constructors

BrowsingContext(IConfiguration?)

Creates a new browsing context with the given configuration, or the default configuration, if no configuration is provided.

public BrowsingContext(IConfiguration? configuration = null)

Parameters

configuration IConfiguration

The optional configuration.

Remarks

This constructor was only added due to PowerShell. See #844 for details.

Properties

Active

Gets or sets the currently active document.

public IDocument? Active { get; set; }

Property Value

IDocument

Creator

Gets the document that created the current context, if any. The creator is the active document of the parent at the time of creation.

public IDocument? Creator { get; }

Property Value

IDocument

Current

Gets the current window proxy.

public IWindow? Current { get; }

Property Value

IWindow

OriginalServices

Gets the original services for the given browsing context.

public IEnumerable<object> OriginalServices { get; }

Property Value

IEnumerable<object>

Parent

Gets the parent of the current context, if any. If a parent is available, then the current context contains only embedded documents.

public IBrowsingContext? Parent { get; }

Property Value

IBrowsingContext

Security

Gets the sandboxing flag of the context.

public Sandboxes Security { get; }

Property Value

Sandboxes

SessionHistory

Gets the session history of the given browsing context, if any.

public IHistory? SessionHistory { get; }

Property Value

IHistory

Methods

CreateChild(string?, Sandboxes)

Creates a new named browsing context as child of the given parent.

public IBrowsingContext CreateChild(string? name, Sandboxes security)

Parameters

name string

The name of the child context, if any.

security Sandboxes

The security flags to apply.

Returns

IBrowsingContext

FindChild(string)

Finds a named browsing context.

public IBrowsingContext? FindChild(string name)

Parameters

name string

The name of the browsing context.

Returns

IBrowsingContext

The found instance, if any.

GetService<T>()

Gets an instance of the given service.

public T? GetService<T>() where T : class

Returns

T

The instance of the service or null.

Type Parameters

T

The type of service to resolve.

GetServices<T>()

Gets all registered instances of the given service.

public IEnumerable<T> GetServices<T>() where T : class

Returns

IEnumerable<T>

An enumerable with all service instances.

Type Parameters

T

The type of service to resolve.

New(IConfiguration?)

Creates a new browsing context with the given configuration, or the default configuration, if no configuration is provided.

public static IBrowsingContext New(IConfiguration? configuration = null)

Parameters

configuration IConfiguration

The optional configuration.

Returns

IBrowsingContext

The browsing context to use.

NewFrom<TService>(TService)

Creates a new browsing context from the given service.

public static IBrowsingContext NewFrom<TService>(TService instance)

Parameters

instance TService

The service instance.

Returns

IBrowsingContext

The browsing context to use.

Type Parameters

TService