Document.URL is a read-only instance property that returns the document location as a string—the address of the current page. Learn how it compares to document.documentURI and location.href, how to display it in the UI, parse URL parts, and five examples with try-it labs.
01
Kind
Read-only
02
Returns
URL string
03
Same as
documentURI
04
Related
location.href
05
Navigate?
Use location
06
Status
Baseline widely
Fundamentals
Introduction
The browser address bar shows where you are on the web. JavaScript can read that same address from the active document through document.URL.
MDN: the URL read-only property of the Document interface returns the document location as a string. MDN also notes that document.documentURI returns the same value.
💡
Read, don’t write
document.URL tells you where the document lives. To go somewhere else, use location.href, location.assign(), or History APIs—not an assignment to document.URL.
Document.URL is marked Baseline Widely available on MDN (since July 2015). Logos use the shared browser-image-sprite.png sprite from this project.
✓ Baseline · Widely available
Document.URL
Read-only string — full document location (same value as documentURI).
WidelyAvailable
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 ExplorerSupported (legacy)
Legacy support
Document.URLBaseline support
Bottom line: Use document.URL to read the page address from a Document. Pair with location or the URL constructor when you need navigation or parsed parts.
Wrap Up
Conclusion
Document.URL is a read-only string that tells you where the current document lives. It matches document.documentURI and usually equals location.href on the active page. Use it to display, log, or parse the address—but use location when you need to navigate.
Use document.URL to read the page address from Document
Compare with document.documentURI when reviewing legacy code
Parse with new URL(document.URL) for structured parts
Use location when you need to navigate or assign href
Log URLs in analytics for reproducible debugging
❌ Don’t
Assign to document.URL (read-only)
Assume it differs from document.documentURI (MDN: same value)
Hand-parse URLs with regex when the URL API exists
Confuse document.URL with document.baseURI
Read cross-origin iframe URLs without expecting security errors
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about document.URL
Read-only document location string.
5
Core concepts
🔗01
Type
String
Read-only
📄02
Value
Location
MDN
🔁03
Alias
documentURI
Same
🚀04
Navigate
location
Not URL
✅05
Status
Baseline
2015+
❓ Frequently Asked Questions
A read-only string with the document location — the full address of the current page (MDN). It is the URL you would use to open this document again.
No. MDN marks Document.URL as Baseline Widely available (since July 2015). It is a standard read-only Document instance property.
MDN states they return the same value. document.URL is the familiar name many developers use; documentURI is the standards-oriented alias on Document.
No. It is read-only on Document. To navigate, use location.href, location.assign(), location.replace(), or History APIs.
Both often return the same string on the active page. Use location when you also need to navigate or read pathname, search, and hash. Use document.URL when you have a Document reference and only need the location string.
Yes — it is the full location string, typically including path, query (?key=value), and fragment (#section) when present.
Did you know?
MDN lists both document.URL and document.documentURI as ways to get the document location, and explicitly states they return the same value. Many codebases use document.URL because the name matches everyday speech—“what’s the page URL?”