-5

ページが更新されるたびにランダムな画像を表示するスクリプトを実行しています。各ランダム画像をクリックすると、クリックしたばかりの画像の下に別の画像が表示されるように設定する方法を知りたいです。2 番目のイメージは、元のイメージごとに異なります。

現在実行中の refresh//random image スクリプトを以下に示します。

助けてください。

<a href="javascript:document.location.reload();"
ONMOUSEOVER="window.status='Refresh'; return true">
<img src="Graphic-design-can-[TEST].png" width="auto" height="auto"//>
</a>

</div>




<div id="outcome">

<script language="JavaScript">

function random_imglink(){
var myimages=new Array()

myimages[1]="expose.png"
myimages[2]="inform.png"
myimages[3]="explain.png"
myimages[4]="formulate.png"
myimages[5]="record.png"
myimages[6]="mediate.png"
myimages[7]="design.png"
myimages[8]="persuade.png"
myimages[9]="summarise.png"
myimages[10]="generate.png" 


var ry=Math.floor(Math.random()*myimages.length)
if (ry==0)
ry=1
document.write('<img src="'+myimages[ry]+'" border=0>')
}
random_imglink()

</script>

ランダムな画像をウェブページにリンクする方法を見つけましたが、上記で説明したように、別の画像を表示する方法も知りたいです。

<a href="javascript:document.location.reload();"
ONMOUSEOVER="window.status='Refresh'; return true">
<img src="Graphic-design-can-[TEST].png" width="auto" height="auto"//>
</a>

</div>

<div id="outcome">

<script language="JavaScript">

function random_imglink(){
var myimages=new Array()
var myurls=new Array()

myimages[1]="expose.png"
myimages[2]="inform.png"
myimages[3]="explain.png"
myimages[4]="formulate.png"
myimages[5]="record.png"
myimages[6]="mediate.png"
myimages[7]="design.png"
myimages[8]="persuade.png"
myimages[9]="summarise.png"
myimages[10]="generate.png" 

myurls[1]="http://google.com"
myurls[2]="http://stackoverflow.com"



var ry=Math.floor(Math.random()*myimages.length)
if (ry==0)
ry=1
document.write('<a href="'+myurls[ry]+'"><img src="'+myimages[ry]+'" border=0 id="someidentification" onClick="'+dosomething()+'") /></a>')
}

random_imglink()
4

1 に答える 1

0

試す

<a href="javascript:document.location.reload();" ONMOUSEOVER="window.status='Refresh'; return true"><img id="randImage" src="" title="" width="auto" height="auto"/>

<script>

   var myimages=new Array()

   myimages[0]="expose1.png"
   myimages[1]="expose.png"
   myimages[2]="inform.png"
   myimages[3]="explain.png"
   myimages[4]="formulate.png"
   myimages[5]="record.png"
   myimages[6]="mediate.png"
   myimages[7]="design.png"
   myimages[8]="persuade.png"
   myimages[9]="summarise.png"
   myimages[10]="generate.png" 

   var rand = myimages[Math.floor(Math.random()*myimages.length)];
   document.getElementById("randImage").src = rand;

   </script>
于 2013-03-25T14:27:02.543 に答える