Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Blob()

Blob() 构造函数返回一个新的 Blob 对象。 blob的内容由给定数组参数值的连结构成。

语法

var aBlob = new Blob( array, options );

参数

  • array 是一个由ArrayBuffer, ArrayBufferView, Blob, DOMString 等对象构成的 Array ,或者其他类似对象的混合体,它将会被放进 Blob.
  • options 是一个可选的Blob熟悉字典,它可能会指定如下两种属性:
    • 类型,默认值为 "",它代表了将会被放入到blob中的数组内容的MIME类型。
    • 结束符,默认值为"transparent",它代表包含行结束符\n的字符串如何被输出。 它是以下两个值中的一个: "native",代表行结束符会被更改为适合宿主操作系统文件系统的惯例,或者 "transparent", 代表会保持blob中保存的结束符不变 

示例

var aFileParts = ['<a id="a"><b id="b">hey!</b></a>']; // an array consisting of a single DOMString
var oMyBlob = new Blob(aFileParts, {type : 'text/html'}); // the blob

标准

Specification Status Comment
File API
Blob()
Working Draft Initial definition.

浏览器兼容性

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 20 13.0 (13.0) [1] 10 12.10 8
in Workers ? 14.0 (14.0) ? ? ?
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? 13.0 (13.0) [1] 未实现 ? ?
in Workers ? 14.0 (14.0) 未实现 ? ?

[1] Firefox16之前,如果第二个参数被设置为null或者undefined,会导致错误,不会自动设置为空字典。

参见

 

文档标签和贡献者

 此页面的贡献者: dukai
 最后编辑者: dukai,