şöyle bir şey yazdım. sanırım işinizi görür.
bu kod sayesinde fonksiyonu bir kez çağırdığınızda aynı imaj 2 kere görüntülenmeyecektir --eğer listede 2 kere yazılmamışsa.
isterseniz printImage fonksiyonunda bastırılacak olan
HTML kodlarını düzenleyebilirsiniz.
<script language="JavaScript">
<!--
function showImages( SHOW )
{
theImages = new Array()
theImages[0] = '100.jpg'
theImages[1] = '200.jpg'
theImages[2] = '300.jpg'
theImages[3] = '400.jpg'
theImages[4] = '500.jpg'
// ======================================
// do not change anything below this line
// ======================================
theImages.sort( sort_rand )
var j = 0;
var p = theImages.length
if ( SHOW > p || SHOW < 1 )
SHOW = 0
var preBuffer = new Array()
for (i = 0; i < p; i++)
{
preBuffer[i] = new image()
preBuffer[i].src = theImages[i]
}
for ( i = 0; i < SHOW; i++ )
{
printImage( theImages[i] )
}
}
function sort_rand( a, b )
{
return Math.floor( Math.random() * 7 )
}
function printImage( src )
{
document.write( '<img src="' + src + '" />' )
}
//-->
</script>
tek yapmanız gereken aynı anda kaç imaj göstermek istiyorsanız o sayıyı parametre olarak yazmanız.
eğer listedekinden fazla ya da negatif bir sayı girerseniz hiç imaj göstermeyecektir.
kolay gelsin..