/    Sign up×
Community /Pin to ProfileBookmark

Random Headers on a HTML Page

I have 5 images set up to fit within the header on my web page. I want each time the pages loads to randomly display 1 of the 5 images in the header… Is this complicated? Anyone got any ideas?

Thanks,
Tom

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@LeeUMay 24.2006 — This should help you [URL=http://javascript.internet.com/image-effects/random-image-script.html]here[/URL]
Copy linkTweet thisAlerts:
@Mr_JMay 24.2006 — Give this a try

[code=php]<script type="text/javascript">
<!--
image = new Array()
image[0] = "pic1.jpg"
image[1] = "pic2.jpg"
image[2] = "pic3.jpg"
image[3] = "pic4.jpg"
image[4] = "pic5.jpg"

function showImg(){
index = Math.floor(Math.random() * image.length);
document.rdm_img.src=image[index]
}

// add onload="showImg()" to the opening BODY tag

//-->
</script>

<img src="" name="rdm_img">

[/code]
×

Success!

Help @tomyknoker 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.18,
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,
)...