/    Sign up×
Community /Pin to ProfileBookmark

html 5 local storage not working

I want to test out local storage html 5 feature
found some sample code( see below)
When I tried their online version it works.
I downloaded their code and created the html file.
When I open it locally and hit the refresh button it doesn’t remember the content. Why is this?

sample code:

<html>
<head>
<title>HTML5 contenteditable example</title>
<script>

function storeUserScribble(id) {
var scribble = document.getElementById(‘scribble’).innerHTML;
localStorage.setItem(‘userScribble’,scribble);
}

function getUserScribble() {
if ( localStorage.getItem(‘userScribble’)) {
var scribble = localStorage.getItem(‘userScribble’);
}
else {
var scribble = ‘<font color=blue face=”Geneva, Arial” size=5><i>You can scribble directly on this sticky… and I will also remember your message the next time you visit my blog!</i></font>’;
}
document.getElementById(‘scribble’).innerHTML = scribble;
}

</script>
</head>

<body>

<p>
<center>

<table width=480 height=480 border=0 cellspacing=0 cellpadding=62>
<td background=”https://www.ibm.com/developerworks/mydeveloperworks/blogs/bobleah/resource/stickynote.jpg” contenteditable=”true” id=”scribble” onkeyup=”storeUserScribble(this.id)”></td>
</table>

<script>
getUserScribble();
</script>

<center>
<p>

</body>
</html>

to post a comment
HTML

3 Comments(s)

Copy linkTweet thisAlerts:
@FangNov 11.2010 — In which browser/version do you have a problem?

IE does not support this in a cell. Place a <p> element in the cell and reference it instead of the cell. localStorage is not supported prior to IE8.
Copy linkTweet thisAlerts:
@webacityauthorNov 11.2010 — Hi

I tried using html 5 compliant browser i.e firefox

Here's another example: http://jsbin.com/iqura/539/edit

However when I create a local file on my hard drive, put in the code, it doesn't remember when refresh button pressed

I have an attached jquery.js file on the local html file
Copy linkTweet thisAlerts:
@FangNov 11.2010 — Have you tried clearing the storage first?[CODE]window.localStorage.clear();[/CODE]
×

Success!

Help @webacity spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...