From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/api/url/revokeobjecturl/index.html | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 files/zh-cn/web/api/url/revokeobjecturl/index.html (limited to 'files/zh-cn/web/api/url/revokeobjecturl/index.html') diff --git a/files/zh-cn/web/api/url/revokeobjecturl/index.html b/files/zh-cn/web/api/url/revokeobjecturl/index.html new file mode 100644 index 0000000000..4619beb7e1 --- /dev/null +++ b/files/zh-cn/web/api/url/revokeobjecturl/index.html @@ -0,0 +1,68 @@ +--- +title: URL.revokeObjectURL() +slug: Web/API/URL/revokeObjectURL +tags: + - API + - URL + - URL API + - 方法 +translation_of: Web/API/URL/revokeObjectURL +--- +
{{ApiRef("URL")}}
+ +

URL.revokeObjectURL() 静态方法用来释放一个之前已经存在的、通过调用 {{domxref("URL.createObjectURL()")}} 创建的 URL 对象。当你结束使用某个 URL 对象之后,应该通过调用这个方法来让浏览器知道不用在内存中继续保留对这个文件的引用了。

+ +

你可以在 sourceopen 被处理之后的任何时候调用 revokeObjectURL()。这是因为 createObjectURL() 仅仅意味着将一个媒体元素的 src 属性关联到一个 {{domxref("MediaSource")}} 对象上去。调用revokeObjectURL() 使这个潜在的对象回到原来的地方,允许平台在合适的时机进行垃圾收集。

+ +

{{AvailableInWorkers}}

+ +

语法

+ +
window.URL.revokeObjectURL(objectURL);
+
+ +

参数

+ +
+
objectURL
+
一个 {{domxref("DOMString")}},表示通过调用 {{domxref("URL.createObjectURL()") }} 方法产生的 URL 对象。
+
+ +

Return value

+ +

undefined

+ +

示例

+ +

查看使用对象 URL 显示图片

+ +

规范

+ + + + + + + + + + + + + + +
规范状态备注
{{SpecName('File API', '#dfn-revokeObjectURL', 'revokeObjectURL()')}}{{Spec2('File API')}}Initial definition
+ +

浏览器兼容性

+ + + +

{{Compat("api.URL.revokeObjectURL")}}

+ +

参见

+ + -- cgit v1.2.3-54-g00ecf