是“localStorage”在火狐浏览器只工作时,页面在线? [英] Is "localStorage" in Firefox only working when the page is online?

查看:409
本文介绍了是“localStorage”在火狐浏览器只工作时,页面在线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在用HTML 5和localStorage,而且我注意到当我在本地主机上的Firefox中运行页面时,我的值才被存储(即 http://127.0.0.1:8000/test/index.html ),但是当我在本地运行文件时(file:/// C:/test/index.html)我的值不被存储。 Safari 4在这两个设置上都没有问题。
所以有人知道这是否是设计 - > Mozilla开发人员中心的DOM存储


(Firefox 2允许在域层次结构
中访问高于当前文档的存储
对象。这是不允许在Firefox 3中允许
更长的时间,因为
的安全原因。另外,这个
除了HTML 5之外,已经从HTML 5规范$ b $中删除
b支持localStorage,即在Firefox 3.5中实现
。)

或者是否有解决方法? >
我想知道,因为离线存储只能在网上工作,听起来很愚蠢:P

如果有人想知道,代码非常简单:


$ b $

  function save()
{
localStorage.setItem('foo','bar');


函数load()
{
var test = localStorage.getItem('foo');
alert(test);


解决方案

一个href =https://bugzilla.mozilla.org/show_bug.cgi?id=507361 =noreferrer> 错误507361 - localStorage不能在file:/// documents

希望很快就会被解决!


$ b 2011-09-13:Bug修复,在'Mozilla8'中实现。我使用Firefox 8测试了这个功能,它现在可以运行。


So I'm toying around with HTML 5 and the localStorage and I'm noticing that my values only get stored when I run the page in Firefox on the local host (i.e. http://127.0.0.1:8000/test/index.html), but when I run the file locally (file:///C:/test/index.html) my values don't get stored. Safari 4 has no problems with both setups. So does anybody know if this is by design -> DOM Storage on the Mozilla Developer Center

(Firefox 2 permitted access to storage objects higher in the domain hierarchy than the current document. This is no longer allowed in Firefox 3, for security reasons. In addition, this proposed addition to HTML 5 has been removed from the HTML 5 specification in favor of localStorage, which is implemented in Firefox 3.5.)

Or if there is a workaround?
I wonder because offline storage that works only online sounds silly :P

If anybody wonders, the code is as easy as it gets:

function save()
{
 localStorage.setItem('foo','bar');
}

function load()
{
 var test = localStorage.getItem('foo');
 alert(test);
}

解决方案

It seems a bug: Bug 507361 - localStorage doesn't work in file:/// documents
Hope is fixed soon!

2011-09-13: Bug fixed, implemented in 'Mozilla8'. I tested this with Firefox 8 and it works now.

这篇关于是“localStorage”在火狐浏览器只工作时,页面在线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆