Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6352237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:09:55+00:00 2026-05-24T22:09:55+00:00

As part of my website projects, I would like to add a script, javascript

  • 0

As part of my website projects, I would like to add a script, javascript or whatever, that changes the background image, but the problem is, I’m don’t know how to program with Java. I only know Lua, HTML, & CSS.

The reason for that is because I’d like the background image to change after 5 seconds (fades into another image) and then again to another. A loop.

I have found something but it’s said that it doesn’t work:

<script language="JavaScript">  


    var Rollpic1 = "1.jpg";
    var Rollpic2 = "2.jpg";
    var Rollpic3 = "3.jpg";

    var PicNumber=1;

    var NumberOfPictures=3;

    var HowLongBetweenPic=5;


    function SwitchPic(counter){

        if(counter < HowLongBetweenPic){

            counter++;


            document.roll.src = eval("Rollpic" + PicNumber);


            CallSwitchPic=window.setTimeout("SwitchPic("+counter+")",1500); 

            }

            else{

                if(PicNumber < NumberOfPictures){
                    PicNumber++;
                    SwitchPic(0);
                }
                else{
                    PicNumber=1;
                    SwitchPic(0);
                    }

            }

    }
    </script>


        <body onload="SwitchPic(0)">        

    <img src="1.jpg" height="300" width="400" border="0" name="roll">
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T22:09:56+00:00Added an answer on May 24, 2026 at 10:09 pm

    This will do it:

    <script>
    document.body.style.backgroundImage="url('path/to/background.png')";
    </script>
    

    Or if you want it to happen when you click something:

    <script>
    function change() {
        document.body.style.backgroundImage="url('path/to/background.png')";
    }
    </script>
    
    <input type="button" onclick="change()" value="Change it" />
    

    To have some code loop on a timer:

    <script>
    function timedCount() {
        // some code here
        setTimeout("timedCount()",1000); //1000 milliseconds
    }
    </script>
    

    Run that function ^ somehow (like with the onclick hander of a button as shown above) and it will loop forever, executing the function every 1000 ms

    By the way, Java has nothing to do with Javascript. They’re completely separate and are very different.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking at building the login/registration part of a website (ASP.NET) and would
My website looks good in Internet Explorer 8 and Firefox but the part of
I have a hyperlink in my website that I want to be part #A0A0A0
So I have my first ever Ruby website up and running and would like
I would like to create a general overview of several Maven projects in the
I feel kinda stupid to even ask that question, But i was sitting like
I would like to write a web interface that resembles Prezi.com in its user
While programming, the longest part is a build on my ASP.NET Website project is
Part of our website is protected with .htaccess style password protection. When you try
I'm working on a part of a website where I generate PDFs, attach them

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.