/    Sign up×
Community /Pin to ProfileBookmark

script for changing images at page refresh

hi evrybody!

i’m looking for a script (maybe java?) that makes an image change whenever i refresh the page:

for example, think about a page with an image “A” in a corner.
when i refresh the page, i’d like this image to be substituded with image “B”

when i refresh, i’d like this image b to be substituted with image A again.

thanks for help!

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@scragarApr 29.2005 — how about with cookies?

[code=php]<script type="text/javascript"><!--
if(document.cookie == "img=1"){
document.write("<img src='firstimg.gif' name='img1' alt='an image'>");
document.cookie = "img=0";
}else{
document.cookie = "img=1";
document.write("<img src='secondimg.gif' name='img1' alt='another image'>");
};
//-->
</script>
<noscript><img src='secondimg.gif' name='img1' alt='another image'></noscript>[/code]
Copy linkTweet thisAlerts:
@sylveeauthorMay 24.2005 — thanks for help...

but i think this code doesn't work, or maybe i'm making some mistakes.


if the images i want to change are:

http://img72.exs.cx/img72/1870/dsc04525p5pc.jpg

and :

http://img72.exs.cx/img72/7369/dsc04805p3us.jpg

then the code will be:

[code=php]<script type="text/javascript"><!--
if(document.cookie == "img=1"){
document.write("<img src='http://img72.exs.cx/img72/1870/dsc04525p5pc.jpg' name='img1' alt='an image'>");
document.cookie = "img=0";
}else{
document.cookie = "img=1";
document.write("<img src='http://img72.exs.cx/img72/7369/dsc04805p3us.jpg' name='img1' alt='another image'>");
};
//-->
</script>
<noscript><img src='http://img72.exs.cx/img72/7369/dsc04805p3us.jpg' name='img1' alt='another image'></noscript>[/code]



is it right? the second image still remains..


another question, if the images are the background of an html page, where and how should i put that tag into this code?:

[code=php]<style>
BODY {background-image:url('http://www.happysumosushi.com/sushi5.gif'); background-position:bottom right;background-repeat:no-repeat; background-attachment:fixed;}
td, body
{font-family:tahoma;font-size:11px;}
.shadow
{FILTER: Glow(Color=#FFFFFF, Strength=6); width: 100%;}
a
{color:#000000}
a:hover
{color:#cc0000}
</style>[/code]




thanks to anybody who will reply! ^_^
Copy linkTweet thisAlerts:
@sylveeauthorMay 25.2005 — please help me : )
×

Success!

Help @sylvee 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.29,
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,
)...