This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.

The Window.URL property returns an object that provides static methods used for creating and managing object URLs. It can also be called as a constructor to construct URL objects.

Note: This feature is available in Web Workers.


Calling a static method:

<var>img</var>.src = URL.<a title="The URL.createObjectURL() static method creates a DOMString containing an URL representing the object given in parameter. The URL lifetime is tied to the document in the window on which it was created. The new object URL represents the specified File object or Blob object." href="dom/URL/createObjectURL"><code>createObjectURL</code></a>(<var>blob</var>);

Constructing a new object:

var <var>url</var> = new <a title="The URL() constructor returns a newly created URL object representing the URL defined by the parameters." href="dom/URL/URL"><code>URL</code></a>("../cats/", "");


Specification Status Comment
The definition of 'URL' in that specification.
Living Standard Initial definition

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 8.0[2] 4.0 (2.0)[1]
19.0 (19.0)
10.0 15.0[2] 6.0[2]
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes)[2] 14.0 (14.0)[1]
19.0 (19.0)
(Yes) 15.0[2] 6.0[2]

[1] From Gecko 2 (Firefox 4) to Gecko 18 included, Gecko returned an object with the non-standard nsIDOMMozURLProperty internal type. In practice, this didn't make any difference.

[2] Implemented under the non-standard name webkitURL.


© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.

API DOM DOM Reference Property Reference Référence