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 4583836
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:16:13+00:00 2026-05-21T21:16:13+00:00

Hello I would like to ask your help regarding javascript code, how do I

  • 0

Hello I would like to ask your help regarding javascript code, how do I have this work?

I have saved the images in my D drive. Do I need to change some path here:

Thanks

<html>
<head>
<script type="text/javascript">

<!--
var image1=new Image()
image1.src="pic001.png"
var image2=new Image()
image2.src="pic002.png"
var image3=new Image()
image3.src="pic003.png"
//-->
</script>
</head>

<body onLoad="slidit()">
<img src="pic001.png" name="slide" width="400" height="120" />


<script>
<!--
//variable that will increment through the images
var step=1
function slideit(){
//if browser does not support the image object, exit.
if (!document.images)
return
document.images.slide.src=eval("images"+step+".src")
if (step<3)
step++
else
step=1
//call function "slideit()" every 1 seconds
setTimeout("slideit()",1000)
}
slideit()
//-->
</script>

</body>


</html>
  • 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-21T21:16:13+00:00Added an answer on May 21, 2026 at 9:16 pm

    I have saved the images in my D drive.
    Do I need to change some path here

    Why give static/absolute path? Use relative path in your webapp. And if you are just practicing with single HTML then just put all the images in same folder in which HTML resides.


    Relative Path

    It means the file path to where the image is located “relative” to the HTML page. In other words you determine the path to the image with the HTML page as the starting point. For example:-

    <img src="../images/img.jpg" />
    

    Absolute Path

    Absolute paths are a different than Relative paths in that it doesn’t matter where the image files are located relative to your web pages. This is because you tell the browser exactly where the file is on the web.Example:-

    <img src=" D/Web/pic001.png" />
    

    See this for more help.


    In your code following is the code where you use image path:

    var image1=new Image()
    image1.src="pic001.png"
    var image2=new Image()
    image2.src="pic002.png"
    var image3=new Image()
    image3.src="pic003.png"
    

    Update:-

    Because your html and images are in same folder you should write like this:

    <script type="text/javascript">
    
    <!--
    var image1=new Image()
    image1.src="pic001.png"
    var image2=new Image()
    image2.src="pic002.png"
    var image3=new Image()
    image3.src="pic003.png"
    //-->
    </script>
    

    My demo working code:

    <html>
        <head>
            <script type="text/javascript">
                var image1 = "./images/img02.jpg"
                var image2 = "./images/img03.jpg"
                var image3 = "./images/img04.jpg"
            </script>
        </head>
        <body onLoad="slidit()">
            <form name="images">
                <img src="./images/img01.jpg" name="slide" width="200" height="200" />
                <script>
                    //variable that will increment through the images
                    var step = 1
                    function slideit(){
                        //if browser does not support the image object, exit.
                        switch(step){
                            case 1:
                                document.images.slide.src = image1;
                                break;
                            case 2:
                                document.images.slide.src = image2;
                                break;
                            case 3:
                                document.images.slide.src = image3;
                                break;
                        }
                        if (step < 3) {
                            step++
                        }
                        else {
                            step = 1
                        }
                        //call function "slideit()" every 1 seconds
                        setTimeout("slideit()", 1000)
                    }
    
                    slideit()
                </script>
            </form>
        </body>
    </html>
    

    Above is my demo code which is working fine. I have made some changes in your code it will now change image on interval. I hope this is what you want. You have to change image path as you used in your code other things are okay and ready to go.

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

Sidebar

Related Questions

Update the question Hello All, I would like improve my email address validation code.
Hello i a probleme i use getListView(); for my list1 and i would like
Hallo There was hopng I could ask for some advice. Which would be the
I would like to alter the functionality of $.prepend() (and probably $.append() ) for
I would like to write an algorithm that compares one memory block with another
Hello I am trying to use regular expressions in a java program. I would
I frequently do this sort of thing: class Person(object): def greet(self): print Hello class
Hello all, I need to create a query for house search, that would match
I have an Enterprise Application with an EJB implementing a @Remote business interface that
Possible Duplicate: How to draw a rectangle on a java applet using mouse drag

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.