--- title: StorageManager.persisted() slug: Web/API/StorageManager/persisted translation_of: Web/API/StorageManager/persisted ---
{{securecontext_header}}{{APIRef("Storage")}}{{SeeCompatTable}}
persisted()
方法是{{domxref("StorageManager")}}的一个接口,如果盒存储模式(box mode)的值为 “persistent” 则返回一个resolved状态值为true
的{{jsxref('Promise')}}。
navigator.storage.persisted().then(function(persistent) { ... })
无
一个状态为resolved,值为{{jsxref('Boolean')}}类型的{{jsxref('Promise')}}。
if (navigator.storage && navigator.storage.persist)
navigator.storage.persisted().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.");
});
Specification | Status | Comment |
---|---|---|
{{SpecName('Storage','#dom-storagemanager-persisted','persisted')}} | {{Spec2('Storage')}} | Initial definition. |
{{Compat("api.StorageManager.persisted")}}