Membuat Random Image pakai Javascript

lg-led-monitor
8 cara Merawat dan membersihkan Layar LCD
July 6, 2009
planters-cactus-plants-indoor-flowers-spines-pictures-types
Kaktus Cegah Radiasi Komputer?
February 28, 2010

Membuat Random Image pakai Javascript

Membuat random image sangatlah mudah, hanya perlu sedikit logika yang matang. .hehe Sebagai contoh random image menggunakan java script adalah ang digunakan pada situs Games . Pada bagian home terdapat gambar2 pada setiap artikelnya, gambar itu random ( kalo ga percaya refresh aja ampe 10x, ga bakalan sama hasilnya :p )

Langsung deh ini javascript buat random image

<script language="JavaScript">
<!-- 
function random_imglink($image){ 
var img=new Array()

//Random image 
img[0]="http://fachrul.com/image1.jpg";
img[1]="http://fachrul.com/image2.jpg";
img[2]="http://fachrul.com/image3.jpg";
img[3]="http://fachrul.com/image4.jpg";

var rd=Math.floor(Math.random()*img.length) if (rd==0) rd=1 document.write("<img src='+img[rd]+' border=0 width='110' height='90'></a>") }

random_imglink() 
//--> 
</script>

4 Comments

  1. hafidz says:

    makasi atas ilmunya . . .

  2. john says:

    Tank infonya saya coba dulu, Salam kenal

  3. i love to play all day on my gamecube. :*:

  4. Olivia Smith says:

    I like both the Gamecube and Xbox, we have them in our home office and also in our living room.~;-

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.