Question: I'm trying to test my local storage so I've tried a few examples.
this example worked before but now its not. not sure what happened

<https://stackoverflow.com/questions/30116818/how-to-use-local-storage-form-with-html-and-javascript?noredirect=1#comment48344527_30116818/>

Now I am trying this code and nothing pops up on if else, it just says local storage is

```
function lsTest() { 
    var test = 'test';
    try {
        localStorage.setItem(test, test);
        localStorage.removeItem(test);
        return true;
    } catch(e) {
        return false;
    }
}

var elem = document.getElementById('status');

if (lsTest() === true) {
    elem.innerHTML += 'available.';
} else {
    elem.innerHTML += 'unavailable.';   
}

```

html

```
<div id="status">Local Storage is </div>

```

full code
<http://tny.cz/39896a73>

Answer: 
You should open your page using a webserver and not your local file system. The browser saves the localstorage data based on the host(domain). This prevents cross site local storage access.
Try this, using a webserver as Nimrodx said.

```js
window.onload = function(){
function lsTest(){ 
    var test = 'test';
  try {
    localStorage.setItem(test, test);
    localStorage.removeItem(test);
    return true;
  } catch(e) {
    console.log(e);
    return false;
  }
}

var elem = document.getElementById('status');

if(lsTest() === true){
  elem.innerHTML += 'available.';
}
else{
  elem.innerHTML += 'unavailable.';   
}
};
```