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

这是 实验性技术
检查 浏览器兼容性表格 要小心谨慎在生产中使用这之前。

persist() 方法在 StorageManager interface requests permission to use persistent storage, and returns a Promise that resolves to true if permission is granted and box mode is persistent, and false 否则。

句法

navigator.storage.persist().then(function(persistent) { ... })
					

参数

None.

返回值

A Promise 解析为 布尔 .

范例

if (navigator.storage && navigator.storage.persist)
  navigator.storage.persist().then(function(persistent) {
    if (persistent)
      console.log("Storage will not be cleared except by explicit user action");
    else
      console.log("Storage may be cleared by the UA under storage pressure.");
  });
					

规范

规范 状态 注释
存储
The definition of 'persist' 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
persist Chrome 52
52
不支持 48 — 52 Alternate Name
Alternate Name Uses the non-standard name: requestPersistent
Edge ≤79 Firefox 55 IE ? Opera Yes Safari ? WebView Android 52
52
不支持 48 — 52 Alternate Name
Alternate Name Uses the non-standard name: requestPersistent
Chrome Android 52
52
不支持 48 — 52 Alternate Name
Alternate Name Uses the non-standard name: requestPersistent
Firefox Android 55 Opera Android Yes Safari iOS ? Samsung Internet Android 6.0
6.0
不支持 5.0 — 6.0 Alternate Name
Alternate Name Uses the non-standard name: requestPersistent

图例

完整支持

完整支持

兼容性未知 ?

兼容性未知

使用非标名称。

元数据

  • 最后修改:
  1. 存储 API
  2. StorageManager
  3. 方法
    1. estimate()
    2. persist()
    3. persisted()
  4. 存储相关页面在该规范中的 NaN 定义。
    1. Navigator.storage
    2. NavigatorStorage
    3. StorageEstimate
    4. WorkerNavigator.storage

版权所有  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1