Request.url

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

Syntax

var myURL = request.url;

Value

A USVString indicating the url of the request.

Example

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

var myRequest = new Request('flowers.jpg');
var myURL = myRequest.url; // "https://mdn.github.io/fetch-examples/fetch-request/flowers.jpg"

Specifications

Browser compatibility

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

See also

© 2005–2021 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