paulmo Posted December 21, 2011 Share Posted December 21, 2011 according to this article I can store data in any browser with html5. unfortunately his script to test it doesn't work even though html5 is in Chrome...console gives me uncaught SyntaxError expected token ILLEGAL. any help greatly appreciated: <script>if (typeof(localStorage) == ‘undefined’ ) {alert(‘Your browser does not support HTML5 localStorage. Try upgrading.’);} else {try {localStorage.setItem(“name”, “Hello World!”); //saves to the database, “key”, “value”} catch (e) {if (e == QUOTA_EXCEEDED_ERR) {alert(‘Quota exceeded!’); //data wasn’t successfully saved due to quota exceed so throw an error};}; document.write(localStorage.getItem(“name”)); //Hello World!localStorage.removeItem(“name”); //deletes the matching item from the database};</script> Link to comment Share on other sites More sharing options...
Ingolme Posted December 21, 2011 Share Posted December 21, 2011 I think the problem may be due to the characters you're using for single and double quotes. Just use ' for single quotes and " for double quotes. Other types of quotation marks aren't valid string delimiters. Link to comment Share on other sites More sharing options...
paulmo Posted December 21, 2011 Author Share Posted December 21, 2011 thanks...changed all quotes to " " error remains. Link to comment Share on other sites More sharing options...
justsomeguy Posted December 21, 2011 Share Posted December 21, 2011 That article is in Wordpress or something which is converting all of the quotes. It's based off this article, start with this code instead: http://html5tutorial.net/tutorials/working-with-html5-localstorage.html Link to comment Share on other sites More sharing options...
paulmo Posted December 22, 2011 Author Share Posted December 22, 2011 thanks jsg, that first example worked. that tutorial will keep me busy for a while. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.