Document.documentURI is a read-only instance property that returns the document location as a string. Learn how it relates to document.URL and location.href, when to use each, and five examples with try-it labs.
01
Kind
Read-only
02
Returns
URL string
03
Same as
document.URL
04
Related
location.href
05
Navigate?
Use location
06
Status
Baseline widely
Fundamentals
Introduction
Every loaded page has an address—the URL you see in the browser bar. JavaScript can read that address in a few ways. One of them is document.documentURI.
MDN: the documentURI read-only property returns the document location as a string. MDN also notes that document.URL returns the same value.
💡
URI vs URL (beginner note)
People often say “URL” for web addresses. “URI” is a broader standards term. For everyday pages, documentURI is simply “this document’s address string.”
Document.documentURI is marked Baseline Widely available on MDN (since April 2018). Logos use the shared browser-image-sprite.png sprite from this project.
✓ Baseline · Widely available
Document.documentURI
Read-only string — the document location (same value as document.URL per MDN).
UniversalWidely available
Google ChromeFull support · Desktop & Mobile
Full support
Mozilla FirefoxFull support · Desktop & Mobile
Full support
Apple SafariFull support · macOS & iOS
Full support
Microsoft EdgeFull support · Chromium
Full support
OperaFull support · Modern versions
Full support
Internet ExplorerNot in legacy IE the same way — use document.URL / location
No / limited
Document.documentURIExcellent
Bottom line: Use document.documentURI (or document.URL) to read the document address. Use location / History to navigate.
Wrap Up
Conclusion
Document.documentURI is the Document API for reading the page address as a string. It matches document.URL; for navigation and URL parts, reach for location.
Use documentURI or document.URL to read the address
Parse with new URL(...) when you need structured parts
Prefer location when navigating or reading pathname/search/hash
Show URIs carefully in UI (user-facing privacy)
Log the URI next to errors for support tickets
❌ Don’t
Assign to document.documentURI
Reimplement URL parsing with brittle string splits
Assume every Document is the top-level page without checking
Confuse document address with document.referrer
Put secrets in the URL and then log documentURI
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about document.documentURI
Read-only document location string — same as document.URL.
5
Core concepts
🔗01
Returns
URL string
API
✓02
Status
baseline
Standard
🔒03
Access
read-only
DOM
🔀04
Same as
document.URL
MDN
🚀05
Navigate
use location
Related
❓ 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 a standard read-only Document instance property.
MDN notes that document.URL returns the same value. 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 history APIs).
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).
Did you know?
The name documentURI comes from DOM / XML-oriented APIs that talk about “document URIs.” On the modern web you will see document.URL and location.href more often in tutorials—but MDN keeps documentURI as a first-class Document property with the same location string.