开发者

Javascript: storing object in globalStorage

Is it possible to store objects in globalStorage or is it only ca开发者_运维百科pable of strings?

One option would be to "jsonify" an object and then store it but I wondered if theres a better way?

var host = location.hostname;

globalStorage[host].test = {
 name1: 'Ben',
 name2: 'John'
};

globalStorage[host].test2 = 'hello';

alert(globalStorage[host].test.name1); //undefined
alert(globalStorage[host].test2); //hello


No, unfortunately data is only stored in globalStorage as strings.

you could take a look at the database object, if your target browser platform supports it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜