Markup: HELP : Randomly Selected Image Reload - javascript

started by Prae on May 13, 2005 — RSS Feed

Prae Prae
Posts: 1

my regards to all here in these forums .

.

i found my way here via this post . http://www.wpdfd.com/cgi-bin/yabb/YaBB.pl?board=js;action=display;num=1098932854

.

it seemed to answer my question as to how i would create a page

with a single . dynamically reloading image . but i've created

another problem .


i had gone about trying to work this out in JAVASCRIPT .

i followed this tutorial =

http://www.picturebridge.com/random-image/]http://www.picturebridge.com/random-image

. . . . . . . .

i used the .ZIP folder at the bottom to reconstruct the sample . i've gotten it to work but once i tried to modify it

it all broke down .

WHAT I'M TRYING TO DO .

is have a dynamically loading IMAGE . WHICH IS ITSELF A "LINK" for a pop up window . also done in java .

. . . . . .

would that doubling up of java somehow conflict or cancel out the affect ? ? ? ?

. . . . . .

this is a link to the test page for this PROBLEM = http://commonalms.com/TEST.htm]http://commonalms.com/TEST.htm

. . . . . . .

and the following is the fairly simple code . i centered the image using a WRAPPER div in the CSS .

. . . . . . . . . . . . . . . . . . . . . . . . . . .

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Reload to display randomly selected image</title>

<link href="layout.css" rel="stylesheet" type="text/css">

<script type="text/javascript" language="javascript">
<!--
function swapPic()
 {
 if(document.getElementById)
   {
   var thePicture=document.getElementById("RandomImage";
   var picPath="001/photo"+rnd(3)+".png";
   thePicture.style.background="url("+picPath+"";
   }
 }
function rnd(n)
 {
 return Math.floor(Math.random() * n) + 1;
 }
//-->
</script>
<style type="text/css">
<!--
body {
     background-image: url(001/blackwhitelineseventeen.gif);
}
-->
</style></head>

<body onload="swapPic()">


<div id="wrapper">


<div id="RandomImage"></div>

</body>
</div>

____________________
____________________

as you can see i am able to get the image to reload . but i can't seem

to use it as a LINK or BUTTON for a pop up window . ( which i need to

do in order to open up my .SWF file )

IF ANYONE COULD LEND SOME FURTHER advice . i'd greatly appreciate it . thanks . again .


LEX

Joe Gillespie Joe Gillespie
Posts: 528

The script you are using is only changing the image. You need to change the image and the attached link. If you use my script (that you alluded to), it will change the image and the link.

Superaverage Superaverage
Posts: 1

I'm looking for similar js code, that will swap a regular image (not background) randomly on browser refresh. I first tried to modify your code, but couldn't make it work. I've been at this for awhile, so many many thanks in advance if you can help...
-scott

Maskodok Eko Maskodok Eko
Posts: 170

TOP SEO | Jasa SEO Profesional

TOP SEO | Jasa SEO Profesional RajaPoker88.com Agen Texas Poker Dan Domino Online Indonesia Terpercaya IDRPoker.COM Agen Texas Poker dan Domino Online Indonesia Terpercaya POKERSTAR88.com Agen Texas Poker Dan Domino Online Indonesia Terpercaya D

You must login to reply