Modernizr has a good simple detect:

https://github.com/Modernizr/Modernizr/blob/master/feature-detects/storage/localstorage.js

It's not too different from what you already have. But I'd say putting the feature detect into it's own function would be worth a couple more lines of code, just to simplify the conditional more than anything.