/    Sign up×
Community /Pin to ProfileBookmark

swapping images everytime return to home page

i am wanting to have an image 800×600 (not a background image) but swapping images. however, there are layers: 1 layer is an image linked to a secondary page, 2 layer is an animated gif linked to a pop window, and several buttons linked to secondary pages, these layers 1,2 and the buttons would all stay static but everytime the user would come back to the home page a new image would appear (the 800×600 image) how do i code this is and is it possible!!!
need your help quickly….
raw

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@Beach_BumDec 20.2002 — a few thoughts -

1) you could use a cookie which increments every time you return to the page. Then based on the cookie value you could load a different image source into the <img> tag. For examples of this you can find cookie based visitor counters on most javascript sites like http://javascript.internet.com/

2) you could use a random number generator (say 1 through 10) and use that number to decide which image source to load into the <img> tag. Of course with a random number it is possible that the same image could come up twice in a row.

The easy way to do either of these would be to sepcify a series of if statements (for the numbers 1-10 for example) which would load the right image source. You don't want to preload all the images into an array in advance as that will kill your page download time.

there may be a slicker way to do this - but that is what comes to mind.
×

Success!

Help @raw_talk 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 6.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...