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
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
documentURIObject | Chrome No support No | Edge No support No | Firefox
No support
? — 57
| IE No support No | Opera No support No | Safari No support No | WebView Android No support No | Chrome Android No support No | Firefox Android
No support
? — 57
| Opera Android No support No | Safari iOS No support No | Samsung 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.