Javascript 如何在 Firefox 中查看/删除本地存储?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6084099/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to view/delete local storage in Firefox?
提问by Ryan
In Google Chrome there is an easy way to see what's in local storage as well as modify or delete it after inspecting it.
在谷歌浏览器中,有一种简单的方法可以查看本地存储中的内容以及在检查后修改或删除它。
Is there a way to do the same in Firefox?
有没有办法在 Firefox 中做同样的事情?
回答by AlexMA
You can delete localStorage items one by one using Firebug(a useful web development extension) or Firefox's developer console.
您可以使用Firebug(一种有用的 Web 开发扩展)或 Firefox 的开发者控制台一个一个地删除 localStorage 项。
Firebug Method
萤火虫法
- Open Firebug (click on the tiny bug icon in the lower right)
- Go to the DOM tab
- Scroll down to and expand localStorage
- Right-click the item you wish to delete and press Delete Property
- 打开 Firebug(点击右下角的小错误图标)
- 转到 DOM 选项卡
- 向下滚动并展开 localStorage
- 右键单击要删除的项目,然后按删除属性
Developer Console Method
开发者控制台方法
You can enter these commands into the console:
您可以在控制台中输入这些命令:
localStorage; // click arrow to view object's properties
localStorage.removeItem("foo");
localStorage.clear(); // remove all of localStorage's properties
Storage Inspector Method
存储检查员方法
Firefox now has a built in storage inspector, which you may need to manually enable. See rahilwazir's answer below.
Firefox 现在有一个内置的存储检查器,您可能需要手动启用它。请参阅下面的 rahilwazir 的回答。
回答by Rahil Wazir
From Firefox 34 onwards you now have an option for Storage Inspector, which you can enable it from developer tools settings
从 Firefox 34 开始,您现在可以选择Storage Inspector,您可以从开发人员工具设置中启用它
Once there, you can enable the Storage
options under Default Firefox Developer tools
在那里,您可以启用默认 Firefox 开发人员工具Storage
下的选项
Updated 27-3-16
27-3-16 更新
Firefox 48.0a1now supports Cookies editing.
Firefox 48.0a1现在支持 Cookies 编辑。
Updated 3-4-16
3-4-16 更新
Firefox 48.0a1now supports localStorage and sessionStorage editing.
Firefox 48.0a1现在支持 localStorage 和 sessionStorage 编辑。
Updated 02-08-16
02-08-16 更新
Firefox 48 (stable release) and onward supports editing of all storage types, except IndexedDB
Firefox 48(稳定版)及更高版本支持编辑所有存储类型,IndexedDB 除外
回答by Thariama
To inspect your localStorage items you may type console.log(localStorage);
in your javascript console (firebug for example or in new FF versions the shipped js console).
要检查您的 localStorage 项目,您可以console.log(localStorage);
在您的 javascript 控制台中键入(例如 firebug 或在新的 FF 版本中,附带的 js 控制台)。
You can use this line of Code to get rid of the browsers localStorage contents. Just execute it in your javascript console:
您可以使用这行代码摆脱浏览器的 localStorage 内容。只需在您的 javascript 控制台中执行它:
localStorage.clear();
回答by Eddie Kumar
As 'localStorage' is just another object, you can: create, view, and edit it in the 'Console'. Simply enter 'localStorage' as a command and press enter, it'll display a string containing the key-value pairs of localStorage (Tip: Click on that string for formatted output, i.e. to display each key-value pair in each line).
由于“localStorage”只是另一个对象,因此您可以:在“控制台”中创建、查看和编辑它。只需输入'localStorage' 作为命令并按回车键,它就会显示一个包含localStorage 键值对的字符串(提示:单击该字符串以进行格式化输出,即在每一行中显示每个键值对)。
回答by Fractalf
There is now a great plugin for Firebug that clones this nice feature in chrome. Check out:
现在有一个很棒的 Firebug 插件可以在 chrome 中克隆这个不错的功能。查看:
https://addons.mozilla.org/en-US/firefox/addon/firestorage-plus/
https://addons.mozilla.org/en-US/firefox/addon/firestorage-plus/
It's developed by Nick Belhomme and updated regularly
它由 Nick Belhomme 开发并定期更新
回答by myusuf
I could not use localStorage
directly in the Firefox (v27) console. I got the error:
我无法localStorage
直接在 Firefox (v27) 控制台中使用。我得到了错误:
[Exception... "Component is not available" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: debugger eval code :: :: line 1" data: no]
[异常...“组件不可用”nsresult:“0x80040111(NS_ERROR_NOT_AVAILABLE)”位置:“JS框架::调试器评估代码::::第1行”数据:否]
What worked was:
有效的是:
window.content.localStorage
回答by E. Varela
Try this, it works for me:
试试这个,它对我有用:
var storage = null;
setLocalStorage();
function setLocalStorage() {
storage = (localStorage ? localStorage : (window.content.localStorage ? window.content.localStorage : null));
try {
storage.setItem('test_key', 'test_value');//verify if posible saving in the current storage
}
catch (e) {
if (e.name == "NS_ERROR_FILE_CORRUPTED") {
storage = sessionStorage ? sessionStorage : null;//set the new storage if fails
}
}
}