Guest User

Untitled

a guest
Jun 29th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script>
  5. function clickCounter() {
  6.  
  7. if(typeof(Storage) !== "undefined") {
  8.  
  9. if(isNaN(parseInt(localStorage.tens))) {
  10. localStorage.tens = 0;
  11. }
  12. if(isNaN(parseInt(localStorage.clickcount))) {
  13. localStorage.clickcount = 0;
  14. }
  15. if (localStorage.clickcount < 10) {
  16. localStorage.clickcount = Number(localStorage.clickcount) + 1;
  17. } else {
  18. localStorage.clickcount = 1;
  19. localStorage.tens = Number(localStorage.tens) + 1;
  20. }
  21. document.getElementById("result").innerHTML = "You have clicked the button " + localStorage.clickcount + " time(s).";
  22. document.getElementById("tens").innerHTML = "Tens: " + localStorage.tens;
  23. } else {
  24. document.getElementById("result").innerHTML = "Sorry, your browser does not support web storage...";
  25. }
  26. }
  27. </script>
  28. </head>
  29. <body>
  30. <p><a href="http://netwars.pl" target="_newtab"><button onclick="clickCounter()" type="button">nw kurwo</a></button>
  31. <div id="result"></div>
  32. <div id="tens"></div>
  33. </p>
  34.  
  35. <p>Click the button to see the counter increase.</p>
  36. <p>Close the browser tab (or window), and try again, and the counter will continue to count (is not reset).</p>
  37. </body>
  38. </html>
Advertisement
Add Comment
Please, Sign In to add comment