javascript - Disable local storage but not cookies in Firefox - Stack Overflow

I would like to create a webpage that will use local storage if it is available, but if not (e.g. the u

I would like to create a webpage that will use local storage if it is available, but if not (e.g. the user's browser doesn't support it), will attempt to use cookies instead. In order to test this functionality on my own puter, which has only modern browsers installed, I'd like to simulate an older browser by disabling local storage while leaving cookies allowed. In Firefox, the dom.storage.enabled option apparently cannot do this, because it affects both local storage AND cookies. Any way around this?

I would like to create a webpage that will use local storage if it is available, but if not (e.g. the user's browser doesn't support it), will attempt to use cookies instead. In order to test this functionality on my own puter, which has only modern browsers installed, I'd like to simulate an older browser by disabling local storage while leaving cookies allowed. In Firefox, the dom.storage.enabled option apparently cannot do this, because it affects both local storage AND cookies. Any way around this?

Share Improve this question asked Oct 10, 2013 at 14:27 baixiweibaixiwei 1,0294 gold badges20 silver badges27 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

Presumably you have something like if(window.localStorage) to test the feature. Dummy it out.

// nuke it pletely:
if( window.localStorage && false)

// add a "debug mode":
if( window.localStorage && !location.href.match(/[?&]nolocalstorage=1/))
// access your page with example./file.html?nolocalstorage=1

There are other ways, of course, but this should give you the general idea.

As a quick and dirty solution, you could run this script in your browser for temporary disabling:

delete window.localStorage;

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745103305a4611405.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信