You might want to check if this works with (older?) Firefox versions that 
support localStorage but have it disabled in about:config - had problems with 
those...

Best,
fry

On 22.9.2011, at 17:36, Michael Haufe (TNO) wrote:

> function supportsStorage(){
>    var ls = window.localStorage;
>    return ls instanceof Object && !isNaN(ls.length);
> }
> 
> 
> On Sep 22, 5:19 am, Anders Jönsson <joensson.and...@gmail.com> wrote:
>> Hi
>> 
>> On "http://diveintohtml5.org/storage.html"; they use the following code to
>> check for local storage support:
>> 
>> function supports_html5_storage() {
>>     try {
>>         return 'localStorage' in window && window['localStorage'] !== null;
>>     } catch (e) {
>>         return false;
>>     }
>> 
>> }
>> 
>> What's the difference between that way and this way?:
>> 
>> function supports_html5_storage() {
>>     try {
>>         return typeof window.localStorage !== 'undefined';
>>     } catch (e) {
>>         return false;
>>     }
>> 
>> }
>> 
>> And can we also remove the try...catch?:
>> 
>> function supports_html5_storage1() {
>>     return typeof window.localStorage !== 'undefined';
>> 
>> }
>> 
>> Is it more safe to use "'localStorage' in window && window['localStorage']
>> !== null; " over "typeof"?
>> 
>> Regards
> 
> -- 
> To view archived discussions from the original JSMentors Mailman list: 
> http://www.mail-archive.com/jsmentors@jsmentors.com/
> 
> To search via a non-Google archive, visit here: 
> http://www.mail-archive.com/jsmentors@googlegroups.com/
> 
> To unsubscribe from this group, send email to
> jsmentors+unsubscr...@googlegroups.com

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com

Reply via email to