我使用localStorage的我Firefox插件以這樣的方式 保持Firefox插件的localStorage當用戶刪除離線數據
var ioService = Components.classes['@mozilla.org/network/io-service;1'].getService(Components.interfaces.nsIIOService);
var scriptSecManager = Components.classes['@mozilla.org/scriptsecuritymanager;1'].getService(Components.interfaces.nsIScriptSecurityManager);
var domStorageManager = Components.classes['@mozilla.org/dom/storagemanager;1'].getService(Components.interfaces.nsIDOMStorageManager);
var uri = ioService.newURI('http://example.com/addon/', null, null);
var principal = scriptSecManager.getNoAppCodebasePrincipal ? scriptSecManager.getNoAppCodebasePrincipal(uri) : scriptSecManager.getCodebasePrincipal(uri);
var localStorage = domStorageManager.getLocalStorageForPrincipal(principal, '');
一切工作正常,但是當用戶刪除「離線數據」存儲已清除。我該如何解決它?
有沒有阻止你使用專門的[存儲API]一個具體的理由(https://developer.mozilla.org/en-US/docs/Storage) ? – unclenorton
我不需要像SQL查詢這樣複雜的東西,我只需要鍵/值存儲。 – KAdot
你確定這個原因嗎? [通過工具 - >選項 - >高級 - >網絡 - >脫機數據 - >立即清除DOM存儲不清除。](https://developer.mozilla.org/zh-CN/docs/DOM/Storage# Storage_location_and_clearing_the_data) – paa