Greeting Message for All Times Of The Day
This is a JavaScript alert message that will greet your visitors with a different message for anytime of the day. This is actually the first JavaScript I have ever wrote so enjoy.
If the user has JavaScript blocked on their browser or their browser does not support it, then they may not see this message. When you entered this page you should of been greeted with a message, if not then you have JavaScript blocked or your browser does not support it.
1 Just add this script below anywhere you want the greeting message to appear. If you add it into a gadget then it will display on all pages in your blog.
Orange message will display from 12am-12pm.
Red message will display from 12pm-6pm
Light Blue message will display from 6pm-12am
3. Optional
If you noticed I colored 2 areas in the bottom of the script. You don't have to change these unless you want to. Basically these are used to change the time the messages will display. Right now the times above will be what time the messages display.
If you do want to change these then you will need to understand what they do. As we all know one day is built up of 24 hours. Well the numbers work from 1-24 with each number referring to the time between the number and the next.
1=1am-2am
2=2am-3am
3=3am-4am
The basic coding syntax for the time is pretty simply to understand.
This above means "If time is less then 11am greet with morning message" ( 11=11am-12pm)
This above means "If time is greater then 5pm greet with night message" (17=5pm-6pm)
Any unassigned time between those two will automatically greet with afternoon message.
Source : http://www.tweakmyblogger.com/2010/11/greeting-message-for-all-times-of-day.html
If the user has JavaScript blocked on their browser or their browser does not support it, then they may not see this message. When you entered this page you should of been greeted with a message, if not then you have JavaScript blocked or your browser does not support it.
1 Just add this script below anywhere you want the greeting message to appear. If you add it into a gadget then it will display on all pages in your blog.
2. Replace the colored text with the message you want to display.
<script type="text/javascript">
function morning(){alert("Good Morning!");}function afternoon(){alert("Good Afternoon!");}function night(){alert("Have a Good Night!");}</script>
<script type="text/javascript">var d = new Date();var time = d.getHours();if (time < 11){morning();}else if (time > 17){night();}else{afternoon();}
</script>
Orange message will display from 12am-12pm.
Red message will display from 12pm-6pm
Light Blue message will display from 6pm-12am
3. Optional
If you noticed I colored 2 areas in the bottom of the script. You don't have to change these unless you want to. Basically these are used to change the time the messages will display. Right now the times above will be what time the messages display.
If you do want to change these then you will need to understand what they do. As we all know one day is built up of 24 hours. Well the numbers work from 1-24 with each number referring to the time between the number and the next.
1=1am-2am
2=2am-3am
3=3am-4am
The basic coding syntax for the time is pretty simply to understand.
if (time < 11) {morning
This above means "If time is less then 11am greet with morning message" ( 11=11am-12pm)
else if (time > 17){night
This above means "If time is greater then 5pm greet with night message" (17=5pm-6pm)
Any unassigned time between those two will automatically greet with afternoon message.
Source : http://www.tweakmyblogger.com/2010/11/greeting-message-for-all-times-of-day.html
0 comments :
Silakan Bekomentar.!!!
Semakin banyak berkomentar, semakin banyak backlink, tapi jangan spam atau post komentar yang berhubungan pornografi!!!
:7: :8: :9: :10: :11: :12:
Post a Comment