createObjectURL method

0 out of 9 rated this helpful - Rate this topic

Creates a URL for the specified object.

Syntax

var retval = URL.createObjectURL(object, oOptions);

Parameters

object [in]

Type: object

The object that needs a URL. This object may be one of the following types:

oOptions [in, optional]

Type: ObjectURLOptions

Used with oneTimeOnly attribute to create a single use URL that does not need to be revoked.

Return value

Type: String

A URL for the specified object.

Remarks

The URL that is created can be used for resources for use with elements such as Image, video, and audio.

The object passed in through object is stored in an internal hash table.

oOptions is set when you want to only use the URL once. The ObjectURLOptions object has one property, oneTimeOnly, that is set to false by default. To set the URL for the object (blob, stream, and so forth) to single use, use the ObjectURLOptions object and set oneTimeOnly to true. For URLs created for MSStream objects, oneTimeOnly is automatically set to true.

To revoke a URL created with createObjectURL, use revokeObjectURL.

Note  Because of image caching, the following code that reuses a single-use Blob URL will work:


myImage2.src = myImage.src = URL.createObjectURL(blob, false);

This is not true for other single-use object URLs.

See also

URL
ObjectURLOptions
revokeObjectURL

 

 

Build date: 11/28/2012

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.