duckmike
duckmike

Reputation: 1036

HTML 5 localStorage not working

I have a simple application written in Visual Studio 2010.

The java script behind a button click:

function btnClicked() {
    alert(localStorage["name"]);
    localStorage["name"] = "Bill";
}

When I click it the first time, I get "undefined" and the second time I get "Bill", which is correct.

But if I restart the application, I'd hope it would display "Bill" the first time I click the button.

It doesn't. What am I missing?

Upvotes: 0

Views: 75

Answers (1)

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324650

But when I restart the application...

... you restart it. Which includes wiping any localStorage contents. Try running your page in a browser and it should work just fine.

Upvotes: 1

Related Questions