安全上下文
此特征只可用于 安全上下文 (HTTPS),在某些或所有 支持浏览器 .

StorageEstimate dictionary's quota property is a conservative approximation of how much storage is allotted to the origin or Web app that called StorageManager.estimate() ; there may be more space available, but there will not be less. This value is an estimate to help prevent its use for fingerprinting—that is, identifying a device using an amalgamation of the values of seemingly innocuous properties.

句法

quota = StorageEstimate.quota;
					

A numeric value specifying an approximation of the total amount of storage space available for use by the application.

范例

In this example, we obtain the usage estimates and present the percentage of storage capacity currently used to the user.

HTML 内容

<label>
  You’re currently using about <output id="percent">
  </output>% of your available storage.
</label>
					

JavaScript 内容

navigator.storage.estimate().then(function(estimate) {
  document.getElementById("percent").value =
      (estimate.usage / estimate.quota * 100).toFixed(2);
});
					

结果

规范

规范 状态 注释
存储
The definition of 'quota' in that specification.
实时标准 初始定义

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
quota Chrome 52 Edge ≤79 Firefox 51 IE ? Opera 42 Safari ? WebView Android 52 Chrome Android 52 Firefox Android 51 Opera Android 42 Safari iOS ? Samsung Internet Android 6.0

图例

完整支持

完整支持

兼容性未知 ?

兼容性未知

另请参阅

元数据

  • 最后修改:
  1. 存储 API
  2. StorageEstimate
  3. 特性
    1. quota
  4. 存储相关页面在该规范中的 NaN 定义。
    1. Navigator.storage
    2. NavigatorStorage
    3. StorageManager
    4. WorkerNavigator.storage