Navigator Class

https://html.spec.whatwg.org/multipage/system-state.html#the-navigator-object: the identity and the state of the user agent. The values are the ones of a desktop user agent that does not support plug-ins nor a PDF viewer.

public sealed class Navigator

Properties

NameDescription
AppCodeNamehttps://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-appcodename
AppNamehttps://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-appname
AppVersionThe user agent string without its "Mozilla/" prefix (https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-appversion).
ClipboardGets the clipboard of the window (https://w3c.github.io/clipboard-apis/#dom-navigator-clipboard).
ConnectionGets the network connection of the device (https://wicg.github.io/netinfo/#navigatornetworkinformation-interface), read from NetworkInformationOptions.Provider.
CookieEnabledhttps://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-cookieenabled
DeviceMemoryGets the approximate memory of the device, in GiB (https://www.w3.org/TR/device-memory/#computing-device-memory-value): ClientHintsOptions.DeviceMemory rounded down to a power of two between 0.25 and 8, or 8 when it is not set. The scripts only see it in a secure context.
DevicePostureGets the posture of the device (https://w3c.github.io/device-posture/#extensions-to-the-navigator-interface).
GeolocationGets the Geolocation API of the window (https://w3c.github.io/geolocation/#navigator_interface).
GlobalPrivacyControlGets whether the user does not consent to the sale or sharing of their data (https://w3c.github.io/gpc/#dom-globalprivacycontrol-globalprivacycontrol): see GlobalPrivacyControlOptions.
HardwareConcurrencyhttps://html.spec.whatwg.org/multipage/workers.html#dom-navigator-hardwareconcurrency
InkGets the Ink API of the window (https://wicg.github.io/ink-enhancement/#dom-navigator-ink): the presenters of delegated ink trails.
KeyboardGets the keyboard of the window (https://wicg.github.io/keyboard-lock/#navigator-interface).
Languagehttps://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-language
LanguagesThe same list is returned until the languages change (https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-languages).
LocksGets the lock manager of the window (https://w3c.github.io/web-locks/#dom-navigatorlocks-locks).
MaxTouchPointsGets the maximum number of simultaneous touch contacts of the device (https://w3c.github.io/pointerevents/#dom-navigator-maxtouchpoints): 1 when the device has a touch screen (ViewportOptions.HasTouch, as the touch emulation of Chromium), 0 otherwise (the touch pointers are injected by the host application, see UserInput).
MediaSessionGets the media session of the window (https://w3c.github.io/mediasession/#dom-navigator-mediasession).
MimeTypeshttps://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-mimetypes
OnLinehttps://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-online: false while the browsing context is offline (BrowsingContext.IsOffline).
Oscpuhttps://html.spec.whatwg.org/multipage/obsolete.html#dom-navigator-oscpu
PdfViewerEnabledhttps://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-pdfviewerenabled
PermissionsGets the Permissions API of the window (https://w3c.github.io/permissions/#dom-navigator-permissions).
Platformhttps://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-platform
Pluginshttps://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-plugins
Producthttps://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-product
ProductSubThe value of the compatibility mode "Gecko" (https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-productsub).
SchedulingGets the scheduling of the window (https://wicg.github.io/is-input-pending/#navigator-extension).
ServiceWorkerGets the service workers of the window (https://w3c.github.io/ServiceWorker/#navigator-service-worker).
StorageGets the storage manager of the window (https://storage.spec.whatwg.org/#dom-navigatorstorage-storage).
UserActivationhttps://html.spec.whatwg.org/multipage/interaction.html#dom-navigator-useractivation
UserAgenthttps://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-useragent
UserAgentDataGets the identity of the user agent given by the User-Agent Client Hints (https://wicg.github.io/ua-client-hints/#dom-navigatorua-useragentdata): the values of BrowsingContextOptions.ClientHints. The scripts only see it in a secure context.
Vendorhttps://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-vendor
VendorSubhttps://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-vendorsub
VirtualKeyboardGets the on-screen keyboard of the window (https://w3c.github.io/virtual-keyboard/#navigator-extension).
WakeLockGets the Screen Wake Lock API of the window (https://w3c.github.io/screen-wake-lock/#extensions-to-the-navigator-interface).

AppCodeName

Navigator.cs

https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-appcodename

public string AppCodeName { get; }

https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-appname

public string AppName { get; }

AppVersion

Navigator.cs

The user agent string without its "Mozilla/" prefix (https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-appversion).

public string AppVersion { get; }

Clipboard

Navigator.cs

Gets the clipboard of the window (https://w3c.github.io/clipboard-apis/#dom-navigator-clipboard).

public Clipboard Clipboard { get; }

Gets the network connection of the device (https://wicg.github.io/netinfo/#navigatornetworkinformation-interface), read from NetworkInformationOptions.Provider.

public NetworkInformation Connection { get; }

CookieEnabled

Navigator.cs

https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-cookieenabled

public bool CookieEnabled { get; }

Gets the approximate memory of the device, in GiB (https://www.w3.org/TR/device-memory/#computing-device-memory-value): ClientHintsOptions.DeviceMemory rounded down to a power of two between 0.25 and 8, or 8 when it is not set. The scripts only see it in a secure context.

public double DeviceMemory { get; }

Property value

double

DevicePosture

DevicePosture.cs

Gets the posture of the device (https://w3c.github.io/device-posture/#extensions-to-the-navigator-interface).

public DevicePosture DevicePosture { get; }

Geolocation

Geolocation.cs

Gets the Geolocation API of the window (https://w3c.github.io/geolocation/#navigator_interface).

public Geolocation Geolocation { get; }

GlobalPrivacyControl

NetworkInformation.cs

Gets whether the user does not consent to the sale or sharing of their data (https://w3c.github.io/gpc/#dom-globalprivacycontrol-globalprivacycontrol): see GlobalPrivacyControlOptions.

public bool GlobalPrivacyControl { get; }

HardwareConcurrency

Navigator.cs

https://html.spec.whatwg.org/multipage/workers.html#dom-navigator-hardwareconcurrency

public ulong HardwareConcurrency { get; }

Gets the Ink API of the window (https://wicg.github.io/ink-enhancement/#dom-navigator-ink): the presenters of delegated ink trails.

public Ink Ink { get; }

Gets the keyboard of the window (https://wicg.github.io/keyboard-lock/#navigator-interface).

public Keyboard Keyboard { get; }

Language

Navigator.cs

https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-language

public string Language { get; }

Languages

Navigator.cs

The same list is returned until the languages change (https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-languages).

public IReadOnlyList<string> Languages { get; }

Gets the lock manager of the window (https://w3c.github.io/web-locks/#dom-navigatorlocks-locks).

public LockManager Locks { get; }

MaxTouchPoints

Navigator.cs

Gets the maximum number of simultaneous touch contacts of the device (https://w3c.github.io/pointerevents/#dom-navigator-maxtouchpoints): 1 when the device has a touch screen (ViewportOptions.HasTouch, as the touch emulation of Chromium), 0 otherwise (the touch pointers are injected by the host application, see UserInput).

public int MaxTouchPoints { get; }

MediaSession

MediaSession.cs

Gets the media session of the window (https://w3c.github.io/mediasession/#dom-navigator-mediasession).

public MediaSession MediaSession { get; }

MimeTypes

Navigator.cs

https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-mimetypes

public PluginMimeTypeArray MimeTypes { get; }

https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-online: false while the browsing context is offline (BrowsingContext.IsOffline).

public bool OnLine { get; }

https://html.spec.whatwg.org/multipage/obsolete.html#dom-navigator-oscpu

public string Oscpu { get; }

PdfViewerEnabled

Navigator.cs

https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-pdfviewerenabled

public bool PdfViewerEnabled { get; }

Permissions

Navigator.cs

Gets the Permissions API of the window (https://w3c.github.io/permissions/#dom-navigator-permissions).

public Permissions Permissions { get; }

Platform

Navigator.cs

https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-platform

public string Platform { get; }

https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-plugins

public PluginArray Plugins { get; }

https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-product

public string Product { get; }

ProductSub

Navigator.cs

The value of the compatibility mode "Gecko" (https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-productsub).

public string ProductSub { get; }

Scheduling

InputPending.cs

Gets the scheduling of the window (https://wicg.github.io/is-input-pending/#navigator-extension).

public Scheduling Scheduling { get; }

ServiceWorker

Navigator.cs

Gets the service workers of the window (https://w3c.github.io/ServiceWorker/#navigator-service-worker).

public ServiceWorkerContainer ServiceWorker { get; }

Property value

ServiceWorkerContainer

Exceptions

DomException
A SecurityError when the origin of the document is opaque (e.g. a sandboxed document), as in the browsers.

See also

Gets the storage manager of the window (https://storage.spec.whatwg.org/#dom-navigatorstorage-storage).

public StorageManager Storage { get; }

UserActivation

Navigator.cs

https://html.spec.whatwg.org/multipage/interaction.html#dom-navigator-useractivation

public UserActivation UserActivation { get; }

UserAgent

Navigator.cs

https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-useragent

public string UserAgent { get; }

Gets the identity of the user agent given by the User-Agent Client Hints (https://wicg.github.io/ua-client-hints/#dom-navigatorua-useragentdata): the values of BrowsingContextOptions.ClientHints. The scripts only see it in a secure context.

public NavigatorUAData UserAgentData { get; }

https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-vendor

public string Vendor { get; }

VendorSub

Navigator.cs

https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-vendorsub

public string VendorSub { get; }

VirtualKeyboard

VirtualKeyboard.cs

Gets the on-screen keyboard of the window (https://w3c.github.io/virtual-keyboard/#navigator-extension).

public VirtualKeyboard VirtualKeyboard { get; }

WakeLock

WakeLock.cs

Gets the Screen Wake Lock API of the window (https://w3c.github.io/screen-wake-lock/#extensions-to-the-navigator-interface).

public WakeLock WakeLock { get; }

Methods

NameDescription
CanShare(ShareData?)Returns whether Navigator.Share would accept the data (https://w3c.github.io/web-share/#canshare-method): false when the document is not fully active, is not allowed to use the web-share feature, or the data is not valid.
ClearAppBadge()Clears the badge of the application (https://w3c.github.io/badging/#clearappbadge-method), as setAppBadge(0).
GetBattery()Returns the battery status of the device (https://w3c.github.io/battery/#the-getbattery-method), read from BatteryStatusOptions.Provider. It returns the same task at each call. The task fails with a NotAllowedError DomException when the document is not allowed to use the battery feature.
JavaEnabled()https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-javaenabled
RegisterProtocolHandler(string, string)Validates the parameters; the handlers are not registered as there is no user to accept them (https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-registerprotocolhandler).
SendBeacon(string, object?)Sends data to url with a POST request that is sent even if the document is unloaded (https://w3c.github.io/beacon/#sendbeacon-method). data is null, a Blob, a byte array, a FormData, a UrlSearchParams or a string. The request is a keepalive request: the method returns false when its body exceeds the quota of the inflight keepalive requests of the document (64 KiB), or when the request is blocked as mixed content or by the Content Security Policy. The response is ignored.
SetAppBadge(ulong?)Sets the badge of the application (https://w3c.github.io/badging/#setappbadge-method), with BadgingOptions.SetBadge: a flag without argument, a number, or nothing when the number is 0. The task fails with an InvalidStateError DomException when the document is not fully active, and a SecurityError when it is not same origin with the top-level document.
Share(ShareData?)Shares data with a target chosen by the user (https://w3c.github.io/web-share/#share-method), with BrowsingContextOptions.Share. The task fails with an InvalidStateError DomException when the document is not fully active or a share is in progress, a NotAllowedError when the document is not allowed to use the web-share feature or has no transient activation, a TypeErrorException when the data is not valid, and an AbortError when there is no share target or the user cancels.
TaintEnabled()https://html.spec.whatwg.org/multipage/obsolete.html#dom-navigator-taintenabled
UnregisterProtocolHandler(string, string)https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-unregisterprotocolhandler
Vibrate(IReadOnlyList<uint>)Vibrates the device with a pattern (https://w3c.github.io/vibration/#vibrate-method), with BrowsingContextOptions.Vibrate: the durations alternate between the vibrations and the pauses. Returns false when the document is hidden or has no sticky activation, true otherwise. An empty pattern, or a pattern of zeros, cancels the current vibration.
Vibrate(uint)Vibrates the device with a pattern (https://w3c.github.io/vibration/#vibrate-method), with BrowsingContextOptions.Vibrate: the durations alternate between the vibrations and the pauses. Returns false when the document is hidden or has no sticky activation, true otherwise. An empty pattern, or a pattern of zeros, cancels the current vibration.

CanShare(ShareData?)

WebShare.cs

Returns whether Navigator.Share would accept the data (https://w3c.github.io/web-share/#canshare-method): false when the document is not fully active, is not allowed to use the web-share feature, or the data is not valid.

public bool CanShare(ShareData? data = null)

Parameters

data ShareData?
The data to share.

Returns

bool

See also

ClearAppBadge()

Badging.cs

Clears the badge of the application (https://w3c.github.io/badging/#clearappbadge-method), as setAppBadge(0).

public Task ClearAppBadge()

GetBattery()

BatteryStatus.cs

Returns the battery status of the device (https://w3c.github.io/battery/#the-getbattery-method), read from BatteryStatusOptions.Provider. It returns the same task at each call. The task fails with a NotAllowedError DomException when the document is not allowed to use the battery feature.

public Task<BatteryManager> GetBattery()

JavaEnabled()

Navigator.cs

https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-javaenabled

public bool JavaEnabled()

RegisterProtocolHandler(string, string)

Navigator.cs

Validates the parameters; the handlers are not registered as there is no user to accept them (https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-registerprotocolhandler).

public void RegisterProtocolHandler(string scheme, string url)

SendBeacon(string, object?)

Navigator.cs

Sends data to url with a POST request that is sent even if the document is unloaded (https://w3c.github.io/beacon/#sendbeacon-method). data is null, a Blob, a byte array, a FormData, a UrlSearchParams or a string. The request is a keepalive request: the method returns false when its body exceeds the quota of the inflight keepalive requests of the document (64 KiB), or when the request is blocked as mixed content or by the Content Security Policy. The response is ignored.

public bool SendBeacon(string url, object? data = null)

Parameters

url string
data object?

Returns

bool

Exceptions

TypeErrorException
The URL is not a valid http or https URL, or the data is a stream.

See also

SetAppBadge(ulong?)

Badging.cs

Sets the badge of the application (https://w3c.github.io/badging/#setappbadge-method), with BadgingOptions.SetBadge: a flag without argument, a number, or nothing when the number is 0. The task fails with an InvalidStateError DomException when the document is not fully active, and a SecurityError when it is not same origin with the top-level document.

public Task SetAppBadge(ulong? contents = null)

Parameters

contents ulong?
The number to show, or null to show a flag.

Returns

Task

See also

Share(ShareData?)

WebShare.cs

Shares data with a target chosen by the user (https://w3c.github.io/web-share/#share-method), with BrowsingContextOptions.Share. The task fails with an InvalidStateError DomException when the document is not fully active or a share is in progress, a NotAllowedError when the document is not allowed to use the web-share feature or has no transient activation, a TypeErrorException when the data is not valid, and an AbortError when there is no share target or the user cancels.

public Task Share(ShareData? data = null)

Parameters

data ShareData?
The data to share.

Returns

Task

See also

TaintEnabled()

Navigator.cs

https://html.spec.whatwg.org/multipage/obsolete.html#dom-navigator-taintenabled

public bool TaintEnabled()

UnregisterProtocolHandler(string, string)

Navigator.cs

https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-unregisterprotocolhandler

public void UnregisterProtocolHandler(string scheme, string url)

Vibrate overloads

Vibrate(IReadOnlyList<uint>)

Vibration.cs

Vibrates the device with a pattern (https://w3c.github.io/vibration/#vibrate-method), with BrowsingContextOptions.Vibrate: the durations alternate between the vibrations and the pauses. Returns false when the document is hidden or has no sticky activation, true otherwise. An empty pattern, or a pattern of zeros, cancels the current vibration.

public bool Vibrate(IReadOnlyList<uint> pattern)
Parameters
pattern IReadOnlyList<uint>
The durations of the vibrations and the pauses, in milliseconds.
Returns

bool

See also

Vibrate(uint)

Vibration.cs

Vibrates the device with a pattern (https://w3c.github.io/vibration/#vibrate-method), with BrowsingContextOptions.Vibrate: the durations alternate between the vibrations and the pauses. Returns false when the document is hidden or has no sticky activation, true otherwise. An empty pattern, or a pattern of zeros, cancels the current vibration.

public bool Vibrate(uint pattern)
Parameters
pattern uint
The duration of the vibration, in milliseconds.
Returns

bool

See also

Constants

NameDescription
DefaultUserAgentThe user agent string of the library (navigator.userAgent when BrowsingContextOptions.UserAgent is null), also sent in the User-Agent header by the hosts that follow it.

DefaultUserAgent

The user agent string of the library (navigator.userAgent when BrowsingContextOptions.UserAgent is null), also sent in the User-Agent header by the hosts that follow it.

public const string DefaultUserAgent = "Mozilla/5.0 (Meziantou.Framework.WebPlatform)"