Request: url property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2017.

The url read-only property of the Request interface contains the URL of the request.

Value

A string indicating the URL of the request.

Examples

In the following snippet, we create a new request using the Request() constructor (for an image file in the same directory as the script), then save the URL of the request in a variable:

js
const myRequest = new Request("flowers.jpg");
const myURL = myRequest.url; // "https://github.com/mdn/dom-examples/tree/main/fetch/fetch-request/flowers.jpg"

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android
url
40Fragment support added in Chrome 59.
14 39
27Fragment support added in Opera 46.
10.1
40Fragment support added in Chrome 59.
39
27Fragment support added in Opera 46.
10.3
4.0Fragment support added in Samsung Internet 7.0.
40Fragment support added in Chrome 59.

See also

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Request/url