Do not attempt to reference localStorage unless it has been verified to exist.

This commit is contained in:
Michael Jumper 2017-04-17 13:23:19 -07:00
parent 2a0a243dd1
commit c7ba6e84b9

View File

@ -71,7 +71,7 @@ GuacamoleSessionStorage = (opener && opener.GuacamoleSessionStorage) || new (fun
// Attempt to read JSON from localStorage, default to local variable
var json = stored_json;
if (localStorage) {
if (window.localStorage) {
try {
json = localStorage.getItem("GUACAMOLE_STATE") || "{}";
}
@ -96,7 +96,7 @@ GuacamoleSessionStorage = (opener && opener.GuacamoleSessionStorage) || new (fun
// Attempt to read JSON from localStorage, default to local variable
var json = stored_json;
if (localStorage) {
if (window.localStorage) {
try {
json = localStorage.getItem("GUACAMOLE_STATE") || "{}";
}
@ -114,7 +114,7 @@ GuacamoleSessionStorage = (opener && opener.GuacamoleSessionStorage) || new (fun
// Attempt to set JSON within localStorage, default to local variable
stored_json = JSON.stringify(obj);
if (localStorage) {
if (window.localStorage) {
try {
localStorage.setItem("GUACAMOLE_STATE", stored_json);
}