Hello sir/madam,
I have this error that I have 2 backgrounds on my webpage after adding a piece of code:
<script>
// Set the date we're counting down to
var countDownDate = new Date("Mar 1, 2019 15:00:00").getTime();
// Update the count down every 1 second
var x = setInterval(function() {
// Get todays date and time
var now = new Date().getTime();
// Find the distance between now and the count down date
var distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
// Display the result in the element with id="demo"
document.getElementById("demo").innerHTML = days + "d " + hours + "h "
+ minutes + "m " + seconds + "s ";
// If the count down is finished, write some text
if (distance < 0) {
clearInterval(x);
document.getElementById("demo").innerHTML = "EXPIRED";
}
}, 1000);
</script>
Well you’re still using var. So you have a leaking scope. Should use const or let.
Also, you’re wasting a lot. There’s no need to manually get the days, hours, minutes, etc. That’s all build into the Date object.
I suggest you look at the prototypes.
Also, when I go to your webpage it is rendering just fine with yellow borders on the side. And in the source I see it is using the no repeat option that @mihawk90 suggested.
Is you want a full-screen background you can use background-size: cover;. You also didn’t specify what exactly it is that you are trying to accomplish, so it’s a little hard to help you out there
Can’t really see anything on first sight, would need ti check at home. Just make sure your JavaScript selectors are executed properly, i.e. they don’t return empty elements or whatever.
Other then that I can’t say much at the moment.
/edit:
This might be a rendering issue on mobile, but in your script file it appears as though the line where it is supposed to write the date string into the element is missing a line break before it, so it’s actually commented out.