使用globalstorage已被弃用。请改用localstorage [英] use of globalstorage is deprecated. please use localstorage instead

查看:274
本文介绍了使用globalstorage已被弃用。请改用localstorage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做一些javascript编程的时候得到了这个消息,经过一些谷歌搜索之后,我不知道这是什么意思,或者我怎么会导致这个错误。我包括下面的代码,有人可以向我解释或指向我的资源如何解决或发生什么?奇怪的是,在程序中我有其他的代码就像这个部分,它从来没有给我错误,所以我很困惑。此外,我只得到这个错误显示与萤火虫运行,否则明智的是不工作,没有错误信息显示。我也试过在Chrome中,并有相同的问题,没有错误消息,但代码不起作用。

  foundTextFn = function(){
console.log('fire');
if(foundTextArrayPosition!= foundTextArray.length){
writeText(foundTextArray [foundTextArrayPosition],happy);
foundTextArrayPosition + = 1;
}
foundTextFnTimer = setTimeout(foundTextFn(),4000);

}



这是我的另一个方法,它基本上是一样的东西,但它工作正常。如果它很重要,所有这些变量是全局变量声明在我的文件开始作为var foundTextArrayPosition = 0;例如。

  awayFn = function(){
if(awayArrayPosition!= awayArray.length){
if(changeAwayState){
changeAwayState = false;
writeText(awayArray [awayArrayPosition],normal);
awayArrayPosition ++;
temp = pickRandomSpot();
randomX = temp [0];
randomY = temp [1];
}
else {
changeAwayState = true;
}
awayTimer = setTimeout(awayFn(),10000);
}
else {
abandoned = true;
whyGoneArrayPosition = 0;
whyGoneFn();


$ / code $ / pre

解决方案

是Firefox 9中的弃用错误。 globalstorage 是一种在Firefox中存储数据的方式,但引入了 localstorage 的HTML5现在是首选的方式(使用 window.localStorage )。


$ b

https://developer.mozilla.org/zh/DOM/Storage 有更多信息。


I got this message when doing some javascript programming, and after some google searches, I have no idea what it means, or how i cause this error. I'm including the code below, can someone explain it to me or point me to a resource on how to fix it or what is happening at all? The weird thing is that I have other code just like this part in my program, and it never gives me errors about them, so i'm really confused. Also, I only get this error to display with firebug running, else wise it just doesn't work and no error message is displayed. I also tried it in Chrome, and had the same issues, no error message but the code doesn't work.

foundTextFn = function(){
console.log('fire');
if (foundTextArrayPosition != foundTextArray.length){
    writeText(foundTextArray[foundTextArrayPosition],"happy");                      
    foundTextArrayPosition += 1;
}
foundTextFnTimer=setTimeout("foundTextFn()",4000);

}

Here is another of my methods, it is basically the same thing, but it works fine. And if it matters, all of these variables are global variables declared at the start of my file as var foundTextArrayPosition = 0; for example.

awayFn = function(){
if (awayArrayPosition != awayArray.length){
        if (changeAwayState){
            changeAwayState = false;
            writeText(awayArray[awayArrayPosition],"normal");
            awayArrayPosition ++;
            temp = pickRandomSpot();
            randomX = temp[0];
            randomY = temp[1];
        }
        else{
            changeAwayState = true;
        }
        awayTimer=setTimeout("awayFn()",10000);
    }
else{
    abandoned = true;
    whyGoneArrayPosition = 0;
    whyGoneFn();
}
}

解决方案

This is a deprecation error in Firefox 9. globalstorage was a way to store data in Firefox, but HTML5 introduced localstorage, which is now the preferred way (using window.localStorage).

https://developer.mozilla.org/en/DOM/Storage has more information.

这篇关于使用globalstorage已被弃用。请改用localstorage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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