Document.documentURIObject

Non-standard
This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

The Document.documentURIObject read-only property returns an nsIURI object representing the URI of the document.

This only works for privileged (UniversalXPConnect) scripts, including extension code. For web content this property doesn't have any special meaning and can be used just like any other custom property.

Privileged code must be careful not to try getting or setting this property on a non-wrapped content object (e.g., on a wrappedJSObject of an XPCNativeWrapper). See bug 324464's comments for details.

Syntax

var uri = document.documentURIObject;

Example

// Check that the URI scheme of the current tab in Firefox is 'http',
// assuming this code runs in context of browser.xul
let uriObj = content.document.documentURIObject;
let uriPort = uriObj.port;

if (uriObj.schemeIs('http')) {
  ...
}

Specifications

Not part of any specification.

Browser compatibility

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
documentURIObject
Non-standard
Chrome No support NoEdge No support NoFirefox No support ? — 57
Notes
No support ? — 57
Notes
Notes Available only to legacy extensions.
IE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoFirefox Android No support ? — 57
Notes
No support ? — 57
Notes
Notes Available only to legacy extensions.
Opera Android No support NoSafari iOS No support NoSamsung Internet Android No support No

Legend

No support
No support
Non-standard. Expect poor cross-browser support.
Non-standard. Expect poor cross-browser support.
See implementation notes.
See implementation notes.