Cope with localStorage not being available

IE10 doesn't allow localStorage for HTML pages loaded from the file://
protocol.
Boo.
This commit is contained in:
Jeremy Ruston 2013-10-29 22:21:25 +00:00
parent d42fb673f8
commit 05e73ee1da
1 changed files with 4 additions and 2 deletions

View File

@ -117,14 +117,16 @@ exports.getBoundingPageRect = function(element) {
Saves a named password in the browser
*/
exports.savePassword = function(name,password) {
localStorage.setItem("tw5-password-" + name,password);
if(window.localStorage) {
localStorage.setItem("tw5-password-" + name,password);
}
};
/*
Retrieve a named password from the browser
*/
exports.getPassword = function(name) {
return localStorage.getItem("tw5-password-" + name);
return window.localStorage ? localStorage.getItem("tw5-password-" + name) : "";
};
/*