Question

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?

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top