I'm trying to make two different backgrounds depending on time. Day/night background. I programmed this but it doesn't work...
<script type="text/javascript">
var currentTime = new Date().getHours();
if (7 <= currentTime && currentTime < 20) {
<style>
html, body {
height: 100%;
margin: 0;
overflow-x: hidden;
overflow-y: auto;
padding: 0;
width: 100%;
background-image: url("bg_day.jpg");
background-repeat: no-repeat;
background-position: center center;
background-attachment: fixed;
}
</style>
}
else {
<style>
html, body {
height: 100%;
margin: 0;
overflow-x: hidden;
overflow-y: auto;
padding: 0;
width: 100%;
background-image: url("bg_night.jpg");
background-repeat: no-repeat;
background-position: center center;
background-attachment: fixed;
}
</style>
}
</script>
Can somebody please help me?