JavaScript Document documentURI Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

Document.documentURI is a read-only string property that returns the document’s location (MDN) — the address of the current document.

Read the notes below before you get or set this property. Prefer feature detection when support is limited.

Syntax

Use document.documentURI. Start with this line.

JavaScript
document.documentURI
CallWhat it does
document.documentURIPrimary signature.

Built into the browser. Read or assign document.documentURI — no import required.

Library declarations
JavaScript
document.documentURI

Parameters

This member has no parameters beyond those shown in the signature.

Return Value

Return ValueDescription
*String (document location)

JavaScript Examples

Example 1 — Read documentURI (MDN Style)

Show the document location string in the page.

JavaScript
document.getElementById("url").textContent = document.documentURI;
Try It Yourself

How It Works

  1. Read the property. document.documentURI is the location string.
  2. Write into the DOM. MDN’s demo puts that string into an element’s text.
  3. Useful for UI. “Current page” labels, debug panels, simple analytics.
  4. No navigation. Reading alone never changes the address.

Example 2 — Compare with document.URL

On a normal page, both strings match.

JavaScript
console.log(document.documentURI);
console.log(document.URL);
console.log(document.documentURI === document.URL);
Try It Yourself

How It Works

  1. Read both APIs. documentURI and URL both report location strings.
  2. Compare with ===. Typical browsing sessions report true.
  3. Either is fine. Teams often standardize on document.URL for brevity.
  4. Still Document APIs. Neither replaces the Location navigation surface.

Example 3 — Compare with location.href

Same address string; different object for navigation.

JavaScript
console.log(document.documentURI);
console.log(location.href);
console.log(document.documentURI === location.href);
// To navigate, assign location.href — not documentURI
Try It Yourself

How It Works

  1. Read Document vs Location. Both expose the current address as text.
  2. Equality check. Usually true while viewing a normal page.
  3. Navigation difference. Assigning location.href loads a new page.
  4. Rule of thumb. Read with documentURI/URL; navigate with location.

Browser Support

Document.documentURI is Baseline Widely available (MDN: since April 2018). Returns the document location as a string.

✓ Baseline · Widely available

Document.documentURI

Read-only location string — same family as document.URL on typical pages.

98% Widely available
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Android WebView Supported · Modern WebView
Full support
documentURI Excellent

Bottom line: Safe for production reads. Prefer location APIs when you need navigation or URL parts (pathname, search, hash).

Frequently Asked Questions

A string with the document’s location (its URL / URI). On a normal web page it is the address of that page.
No. MDN marks Document.documentURI as Baseline Widely available (since April 2018). It is not Deprecated, Experimental, or Non-standard.
They return the same location string. Prefer either; many codebases use document.URL or location.href for everyday work.
location.href is on the Location object and is commonly used for reading and navigating. documentURI is a Document property that reports the document location as a string (read-only on Document).
No. It is read-only on Document. To navigate, use location.assign / location.href (or the History API).
Yes — like a full page URL string, it typically includes path, query, and fragment when present (same family of values as document.URL / location.href).

Next: domain

Learn the Document property related to the document’s domain.

domain tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful