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 badges2 Answers
Reset to default 5Presumably 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;