Greeting Message to the User
Submitted by azalea zenith on Tuesday, October 11, 2016 - 15:02.
This simple script that I create using JavaScript jQuery that will message the user then this program will greet the user base on the current time. Use this simple program to be polite to the user and it shows to the user how much they important in every visit to the website.
Live Demo
All source code construct using jQuery script. Let's construct one by one.
This simple script greeting to the user for the Morning. This would be like the script.
This one, for the noon greetings to the user.
And, for the afternoon greetings to the user.
This time for the evening greetings to the user.
After that, this greeting would be a good night for the user.
Lastly, this greeting is for the user who sleeps in the late night.
Complete Script
- if (hours >= 5 && hours <= 11)
- //GREETING MESSAGE FOR MORNING
- document.write('<div class="alert alert-info" role="alert"><h2>Hello! Good Morning! Have a nice day.</h2></div>')
- if (hours == 12)
- //GREETING MESSAGE FOR NOON
- document.write('<div class="alert alert-info" role="alert"><h2>Good Noon Visitor! </h2></div>')
- if (hours >= 13 && hours <= 17)
- //GREETING MESSAGE FOR AFTERNOON
- document.write('<div class="alert alert-info" role="alert"><h2 style="color:#1982d1;">Good Afternoon! </h2></div>')
- if (hours >= 18 && hours <= 20)
- //MESSAGE FOR EVENING (6pm-8pm)
- document.write('<div class="alert alert-info" role="alert"><h2>Good Evening! </h2></div>')
- if (hours >= 21 && hours <= 11)
- //GREETING MESSAGE FOR NIGHT (9pm-11pm)
- document.write('<div class="alert alert-info" role="alert"><h2>Good Night! </h2></div>')
- else
- //GREETING MESSAGE FOR LATE NIGHT (12pm-4am)
- document.write('<div class="alert alert-info" role="alert"><h2>Wow! You`re still awake. Working Late?</h2></div>')
- <script>
- var current_time = new Date()
- var hours = current_time.getHours()
- if (hours >= 5 && hours <= 11)
- //GREETING MESSAGE FOR MORNING
- document.write('<div class="alert alert-info" role="alert"><h2>Hello! Good Morning! Have a nice day.</h2></div>')
- else if (hours == 12)
- //GREETING MESSAGE FOR NOON
- document.write('<div class="alert alert-info" role="alert"><h2>Good Noon Visitor! </h2></div>')
- else if (hours >= 13 && hours <= 17)
- //GREETING MESSAGE FOR AFTERNOON
- document.write('<div class="alert alert-info" role="alert"><h2 style="color:#1982d1;">Good Afternoon! </h2></div>')
- else if (hours >= 18 && hours <= 20)
- //MESSAGE FOR EVENING (6pm-8pm)
- document.write('<div class="alert alert-info" role="alert"><h2>Good Evening! </h2></div>')
- else if (hours >= 21 && hours <= 11)
- //GREETING MESSAGE FOR NIGHT (9pm-11pm)
- document.write('<div class="alert alert-info" role="alert"><h2>Good Night! </h2></div>')
- else
- //GREETING MESSAGE FOR LATE NIGHT (12pm-4am)
- document.write('<div class="alert alert-info" role="alert"><h2>Wow! You`re still awake. Working Late?</h2></div>')
- </script>
Add new comment
- 269 views