only use localStorage if available
This commit is contained in:
parent
a87f5632bc
commit
df6eed44cf
1 changed files with 3 additions and 3 deletions
|
@ -1472,7 +1472,7 @@ SquareGridControl = L.Control.extend({
|
|||
this._button.href = '#';
|
||||
this._button.style.color = '#BBBBBB';
|
||||
this.gridActive = false;
|
||||
if (localStorage.getItem('showGrid')) {
|
||||
if (localStorage && localStorage.getItem('showGrid')) {
|
||||
this.showGrid()
|
||||
}
|
||||
return this._container;
|
||||
|
@ -1493,7 +1493,7 @@ SquareGridControl = L.Control.extend({
|
|||
this._button.innerHTML = 'grid_on';
|
||||
this._button.style.color = '';
|
||||
this.gridActive = true;
|
||||
localStorage.setItem('showGrid', true);
|
||||
if (localStorage) localStorage.setItem('showGrid', true);
|
||||
},
|
||||
|
||||
hideGrid: function() {
|
||||
|
@ -1502,7 +1502,7 @@ SquareGridControl = L.Control.extend({
|
|||
this._button.innerHTML = 'grid_off';
|
||||
this._button.style.color = '#BBBBBB';
|
||||
this.gridActive = false;
|
||||
localStorage.removeItem('showGrid');
|
||||
if (localStorage) localStorage.removeItem('showGrid');
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue