/    Sign up×
Community /Pin to ProfileBookmark

How to change images when window is reloaded

Hi ,

I have 4 images. When the page loads I want to display the first image, then, when the page loads again (refreshed by the user), display the next image, and so on. Can someone help me with the script to do this.

Thanks,
Leo

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@JPnycOct 06.2004 — I'll tell you how you have to proceed. 1st off, use a session variable/ Then you create an array with the 4 pics, and an index, which will be the session variable. Call the function onload, increment the session variable each pass.
Copy linkTweet thisAlerts:
@David_HarrisonOct 06.2004 — If you're not bothered about the order that the images appear in, something like the script I've attached would do nicely.

There's a noscript tag to cater for those who do not have JavaScript enabled and then there is an empty paragraph (which the image gets put into).

You can add images to the array by using the addImage function. The addImage function has four arguements and they are as follows:

* The image source

*
The image width

* The image height

*
The images alternate text

All four are REQUIRED otherwise the script will throw a wobbler.

[upl-file uuid=25c66c23-f287-47a3-9685-80450e4fb57f size=1kB]random_image.txt[/upl-file]
Copy linkTweet thisAlerts:
@David_HarrisonOct 09.2004 — Any good?
×

Success!

Help @leonard905 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...