ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

supports_html5_storage()

Function to determine if the browser supports HTML 5 local storage.

Source

function supports_html5_storage() {
    try {
        return 'localStorage' in window && window['localStorage'] !== null;
    } catch (e) {
        return false;
    }
}

Example

if(supports_html5_storage()) {
 // do whatever
}

Author: John D. Sanders

Submitted on: 15 jan. 2014

Language: JavaScript

Type: HTML5 Local Storage

Views: 6139