[color=red]1st Variant[/color]
Script dibawah ini bakal buat warna latar belakang background kamu jadi berubah setiap detiknya.
[quote]var Nilai = 0;
function LatarBelakangKilat()
{
Warna = [[b]"black","maroon","green","navy",
"silver","red","lime","blue",
"gray","purple","olive","teal",
"white","fuchsia","yellow","aqua"[/b]];
document.bgColor = Warna[Nilai];
Nilai = Nilai + 1;
if (Nilai > 15) //jika nilainya 15 akan kembali ke nol/awal
{
Nilai = 0;
}
setTimeout("LatarBelakangKilat()",2000);
}
document.write("var Nilai = 0;
function LatarBelakangKilat()
{
Warna = [b]["black","maroon","green","navy",
"silver","red","lime","blue",
"gray","purple","olive","teal",
"white","fuchsia","yellow","aqua"[/b]];
document.bgColor = Warna[Nilai];
Nilai = Nilai + 1;
if (Nilai > 15) //jika nilainya 15 akan kembali ke nol/awal
{
Nilai = 0;
}
setTimeout("LatarBelakangKilat()",2000);
}
var Nilai = 0;
function LatarBelakangKilat()
{
Warna = ["black","maroon","green","navy",
"silver","red","lime","blue",
"gray","purple","olive","teal",
"white","fuchsia","yellow","aqua"];
document.bgColor = Warna[Nilai];
Nilai = Nilai + 1;
if (Nilai > 15) //jika nilainya 15 akan kembali ke nol/awal
{
Nilai = 0;
}
setTimeout("LatarBelakangKilat()",2000);
}
document.write("<body onload="LatarBelakangKilat()">");[/quote]
Yang di bold bisa diganti tapi saya tidak bertanggung jawab apabila scriptnya ga jalan... hahaha
Preview:
http://h1.ripway.com/tommywinarta/latar1.html
[color=red]2nd Variant[/color]
Script dibawah ini bakal membuat warna latar berlakang background anda berubah sesuai warna yang anda klik
[quote]Merah=5
Hijau=0
Biru=0
warnalatarbelakang="#000000"
function Konversi(Nil)
{
warna=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];
return(warna[Nil]);
}
function setLatarBelakang(Nilai)
{
if (Nilai==1)
{
if (Merah<15)
{
Merah=Merah+1;
}
}
if (Nilai==2)
{
if (Hijau<15)
{
Hijau=Hijau+1;
}
}
if(Nilai=
)
{
if (Biru<15)
{
Biru=Biru+1;
}
}
if (Nilai==4)
{
if (Merah>0)
{
Merah=Merah-1;
}
}
if (Nilai==5)
{
if (Hijau>0)
{
Hijau=Hijau-1;
}
}
if (Nilai==6)
{
if (Biru>0)
{
Biru=Biru-1;
}
}
warnalatarbelakang="#"+Konversi(Merah)+"0"+Konversi(Hijau)+"0"+Konversi(Biru)+"0";
document.bgColor = warnalatarbelakang
}[/quote]
Lalu, masukan kode dibawah sebagai addbox:
[quote]<table border="1" width="53%">
<tr>
<td width="100%">
<p align="center">Tabel Warna Latar Belakang</p></td>
</tr>
</table>
<table border="1" width="53%">
<tr>
<td width="11%"><input type="button" value="+ Merah" onclick="setLatarBelakang(1)"></td>
<td width="11%"><input type="button" value="- Merah" onclick="setLatarBelakang(4)"></td>
<td width="10%"><input type="button" value="+ Hijau" onclick="setLatarBelakang(2)"></td>
<td width="10%"><input type="button" value="- Hijau" onclick="setLatarBelakang(5)"></td>
<td width="9%"><input type="button" value="+ Biru" onclick="setLatarBelakang(3)"></td>
<td width="49%"><input type="button" value="- Biru" onclick="setLatarBelakang(6)"></td>
</tr>
</table>
<table border="1" width="53%">
<tr>
<td width="100%">
<p align="center">Pilih '+" atau '-' terus menerus untuk merubah warna latar belakang</p>
</td>
</tr>
</table>[/quote]
Preview:
http://h1.ripway.com/tommywinarta/latar2.html
[color=red]3rd Variant[/color]
[quote]function AmbilHari()
{
var D
Warna=" ";
Day=["Minggu","Senin","Selasa","Rabu","Kamis","Jumat","Sabtu"];
Tanggal=new Date();
D = Tanggal.getDay();
if (D==0)
{
Warna="blue";
}
if (D==1)
{
Warna="red";
}
if (D==2)
{
Warna="yellow";
}
if (D=
)
{
Warna="maroon";
}
if (D==4)
{
Warna="brown";
}
if (D==5)
{
Warna="orange";
}
if (D==6)
{
Warna="green";
}
[b]alert("Hallo!!! Warna untuk hari "+Day[D]+" adalah "+Warna);[/b]
<!-- ubah warna latar belakang sesuai dengan hari -->
document.bgColor=Warna;
}
document.write('<body onLoad="AmbilHari()">');[/quote]
No Preview Temporarily
[color=red]4th Variant[/color]
Background color fader
Hapir mirip variant kesatu tapi.... Lihat aja deh bedanya!
[quote]A=0;
Warna="";
EfekFade();
function EfekFade()
{
if (A==0)
{
Warna="#000000";
}
if (A==1)
{
Warna="#111111";
}
if (A==2)
{
Warna="#222222";
}
if (A=
)
{
Warna="#333333";
}
if (A==4)
{
Warna="#444444";
}
if (A==5)
{
Warna="#555555";
}
if (A==6)
{
Warna="#666666";
}
if (A==7)
{
Warna="#777777";
}
if (A==8)
{
Warna="#888888";
}
if (A==9)
{
Warna="#999999";
}
if (A==10)
{
Warna="#aaaaaa";
}
if (A==11)
{
Warna="#bbbbbb";
}
if (A==12)
{
Warna="#cccccc";
}
if (A==13)
{
Warna="#dddddd";
}
if (A==14)
{
Warna="#eeeeee";
}
if (A==15)
{
Warna="#ffffff";
}
A++;
document.bgColor=Warna;
setTimeout("EfekFade()",1000);
}[/quote]
Perview!
http://h1.ripway.com/tommywinarta/fade.html
[color=red]5th Variant[/color]
Jadikan sebgai addbox:
[quote]<form>
<select size="5" name="warna" onchange="document.bgColor=this.options[this.selectedIndex].value">
<option value="white" selected>putih</option>
<option value="red">Merah</option>
<option value="green">Hijau</option>
<option value="gold">Gold</option>
<option value="yellow">Kuning</option>
<option value="blue">Biru</option>
<option value="salmon">Salmon</option>
<option value="lime">Lime</option>
</select>
</form>[/quote]
Taruh semua js diatas di bagian a dan kode sebagai addbox di onload handler atau bagian b.
[color=red]Perhatian![/color]Jangan menaruh kelima script diatas bersamaan! Dapat terjadi bentrok
Last edited by ymm0t (2008-07-02 21:08:45)