Skip to main content

Forums

This topic contains 17 replies, has 10 voices, and was last updated by  sagarleo1 1 month, 1 week ago.

Viewing 3 posts - 16 through 18 (of 18 total)
  • Author
    Posts
  • #279755

    docwest
    Participant

    Rather then 10 seconds how about 24 hours a new background.

    #279757

    Shikkediel
    Participant

    I think that would either have to be coded server side (in case the page is not served with only HTML but is inserted with PHP for example) or if you want an approach on the user’s end, you could go with window.localStorage and check the last time the page was visited – if that was more than a day ago, then change the background.

    #280907

    sagarleo1
    Participant

    Hii, I have given you the code (JavaScript), try it yourself and share the result

    var i = 0;
    function change() {
    var doc = document.getElementById(“background”);
    var color = [“black”, “blue”, “brown”, “green”];
    doc.style.backgroundColor = color[i];
    i = (i + 1) % color.length;
    }
    setInterval(change, 1000);

    &nbsp
Viewing 3 posts - 16 through 18 (of 18 total)

You must be logged in to reply to this topic.

icon-link icon-logo-star icon-search icon-star