我对此完全陌生,所以请耐心等待。我希望在每次刷新或加载时旋转此页面http://jovanatanakovic.com/index.html上的主图像。我找到了这个并尝试将它添加到脚本标签中
function random_imglink(){
var theImages = new Array()
theIimages[1]="images/thalia-heffernan-4.jpg"
theImages[2]="images/volcano-surfing-the-ascent.jpg"
theImages[3]="images/rooster-fighting-sucking-blood-from-face.jpg"
theImages[4]="images/cooper-canyon-fallen-tarahumara.jpg"
theImages[5]="images/copper-canyon-finishers.jpg"
var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
preBuffer[i] = new Image()
preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
if(whichImage==0){
document.write('<a href =""><img src="'+theImages[whichImage]+'" border=0 width=689 height=466></a>');
} else if(whichImage==1){
document.write('<a href ="link.html"><img src="'+theImages[whichImage]+'" border=0 width=689 height=466></a>');
} else if(whichImage==2){
document.write('<a href ="link.html"><img src="'+theImages[whichImage]+'" border=0 width=689 height=466></a>');
} else if(whichImage==3){
document.write('<a href ="link.html"><img src="'+theImages[whichImage]+'" border=0 width=689 height=466></a>');
} else if(whichImage==4){
document.write('<a href ="link.html"><img src="'+theImages[whichImage]+'" border=0 width=689 height=466></a>');
}
}
我被告知在我希望图像显示的地方添加这个
<script>showImage();</script>
这个对吗?我确定将它放在哪里,因为当前图像附加了 css。我试过将它添加到 div 标签中。