Last active
August 29, 2015 14:27
-
-
Save santosh/3632fe4c9a52a9c11acf to your computer and use it in GitHub Desktop.
Put time in localstorage if user visits for first time and retrieve later when the webpage was visited.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html dir="ltr" lang="en"> | |
| <head> | |
| <meta charset="utf-8" /> | |
| <title> Loopingtriangle </title> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> | |
| <meta name="viewport" content="width=device-width,initial-scale=1.0"/> | |
| </head> | |
| <body> | |
| <script charset="utf-8"> | |
| if (localStorage.getItem('tim')) { | |
| document.write("Welcome back, you visited this website earlier on " + localStorage.getItem('tim')); | |
| } | |
| var tim = new Date(); | |
| document.write("<br />The time now is ", +tim, " storing in your localStorage"); | |
| localStorage.setItem('tim', +tim); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment