Jump to content

Java / HTML image change

Go to solution Solved by fjdhdhcyfhf,

create an array of image URLs,

create a variable to use as index to the array

create a new javascript function that does the following:

increment the index 

check the index is not greater than image array length, if yes reset to zero

use document.getelementbyid() to get the image element

set the image element.src = imageArray[index]

 

create an array of image URLs,

create a variable to use as index to the array

create a new javascript function that does the following:

increment the index 

check the index is not greater than image array length, if yes reset to zero

use document.getelementbyid() to get the image element

set the image element.src = imageArray[index]

 

             ☼

ψ ︿_____︿_ψ_   

Link to comment
https://linustechtips.com/topic/685131-java-html-image-change/#findComment-8800600
Share on other sites

Link to post
Share on other sites

A system I might want to build adds to Schischka's idea. Loading the previous and next image, in a hidden div. When you would click next or previous, the image was already loaded, so really fast to respond. In the mean time, the new (next or previous) image gets loaded inside the hidden div, so you don't really notice possible load times at all.

Link to comment
https://linustechtips.com/topic/685131-java-html-image-change/#findComment-8800633
Share on other sites

Link to post
Share on other sites

 

18 minutes ago, SCHISCHKA said:

create an array of image URLs,

create a variable to use as index to the array

create a new javascript function that does the following:

increment the index 

check the index is not greater than image array length, if yes reset to zero

use document.getelementbyid() to get the image element

set the image element.src = imageArray[index]

 

Thanks dude. Will try it out tomorrow.

Have you tried turning it off and on again?

Link to comment
https://linustechtips.com/topic/685131-java-html-image-change/#findComment-8800641
Share on other sites

Link to post
Share on other sites

5 hours ago, Dutch-stoner said:

A system I might want to build adds to Schischka's idea. Loading the previous and next image, in a hidden div. When you would click next or previous, the image was already loaded, so really fast to respond. In the mean time, the new (next or previous) image gets loaded inside the hidden div, so you don't really notice possible load times at all.

To be honest it's for school course work so I am not really bothered about speed. Might still give it ago though. 

Have you tried turning it off and on again?

Link to comment
https://linustechtips.com/topic/685131-java-html-image-change/#findComment-8801944
Share on other sites

Link to post
Share on other sites

6 hours ago, Dutch-stoner said:

A system I might want to build adds to Schischka's idea. Loading the previous and next image, in a hidden div. When you would click next or previous, the image was already loaded, so really fast to respond. In the mean time, the new (next or previous) image gets loaded inside the hidden div, so you don't really notice possible load times at all.

OK. The images are of such a small size, kb, I don't think I need to. 

Have you tried turning it off and on again?

Link to comment
https://linustechtips.com/topic/685131-java-html-image-change/#findComment-8802100
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×