Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to change page background on the day time basis using Javascript

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 374
    Comment on it

    Hello Reader's! If you want to change your web background image automatic on the day time basis, i.e. for day it will show pic 1 and in night it will show pic 2 as background.

    Lets see the full example below:-

    </body>
    <script type="text/javascript">
    var currentTime = new Date().getHours();
    if (7 <= currentTime && currentTime < 20) {
        if (document.body) {
            document.body.background = "http://itsnotch.com/tumblr/images/daytime_bg.jpg";
        }
    }
    else {
        if (document.body) {
            document.body.background = "http://itsnotch.com/tumblr/images/nighttime_bg.jpg";
        }
    }
    
    </script>
    </html>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: