You can easily customize this script to change the css file of the website to get a complete new look of your website. To use this script you need to add the following code before the </head> tag.
<script> var now = new Date(); var hours = now.getHours(); var psj=0; //This is for time 18-19 hours if (hours > 17 && hours < 20){ document.write('<body bgcolor="orange" text="#FFFFFF">') } //This is for time 20-21 hours if (hours > 19 && hours < 22){ document.write('<body bgcolor="orangered" text="#FFFFFF">') } //This is for time 22-4 hours if (hours > 21 || hours < 5){ document.write('<body bgcolor="black" text="#FFFFFF">') } //This is for time 9-17 hours if (hours > 8 && hours < 18){ document.write('<body bgcolor="deepskyblue" text="#FFFFFF">') } //This is for time 7-8 hours if (hours > 6 && hours < 9){ document.write('<body bgcolor="skyblue" text="#FFFFFF">') } //This is for time 5-6 if (hours > 4 && hours < 7){ document.write('<body bgcolor="steelblue" text="#FFFFFF">') } </script>
I will explain this code -
We have defined a new variable "now", which calls the current date and time of the local computer. (The computer where the website is open currently, so it can be used globally)
Next on line 3 we have taken new variable (hours) only hours from the first variable.
After that we have used if statements to verify the time of the day and then if the statement if true the specific document.write function is processed.
You can customize this code in the way you want, and use it personally as well as professionally.
Just don't forget to comment if you find it useful.
No comments:
Post a Comment
Comment anything you want. Just be polite and give respect to others!
I am simply going to remove the comments which are offensive or are off topic.
And please don't spam your website links in comments. I don't, neither should you.