Joelthezombie15 Posted March 16, 2014 Share Posted March 16, 2014 So i am doing the web storage tutorial and its not working. i eve tried it in the text editor and it still wont work. it looks exactly the same (Unless im missing something) but it wont work. heres my code. <head> <script> function clickCounter() { if (typeof(Storage)!=="undefined") { if (localStorage.clickcount) { localStorage.clickcount=Number(localStorage.clickcount)+1; } else { localStorage.clickcount=1; } document.getElementById("result").innerHTML="You have clicked the button" + localStorage.clickcount + " time(s)."; } else { document.getElementById("result") .innerHTML="Sorry, your browser does not support web storage..."; } } </script> </head> <body> <p><button onclick="clickCounter()" type="button">Click me!</button></p> <div id="result"></div> <p>Click the button to see the counter increase.</p> <p>Close the browser tab (or window), and try again, and the counter will continue to count (is not reset).</p> </body> </html> Link to comment Share on other sites More sharing options...
davej Posted March 17, 2014 Share Posted March 17, 2014 <!DOCTYPE html><head><meta charset="utf-8"><title>tab</title><script>window.onerror = function(m, u, l){alert('Javascript Error: '+m+'nURL: '+u+'nLine Number: '+l);return true;}</script><script>function clickCounter(){if (typeof(Storage)!=="undefined"){if (localStorage.clickcount){localStorage.clickcount=Number(localStorage.clickcount)+1;}else{localStorage.clickcount=1;}document.getElementById("result").innerHTML="You have clicked the button" + localStorage.clickcount + "time(s).";}else{document.getElementById("result") .innerHTML="Sorry, your browser does not support web storage...";}}</script></head><body><p><button onclick="clickCounter()" type="button">Click me!</button></p><div id="result"></div><p>Click the button to see the counter increase.</p><p>Close the browser tab (or window), and try again, and the counter will continue to count (is not reset).</p> </body></html> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now