Efek lapisan popup JavaScript
Penulis:Eve Cole
Waktu Pembaruan:2009-06-11 16:22:38
fungsi peringatan(str){
var pesan, msgh, warna batas;
msgw=400; //Lebar jendela perintah
msgh=100;//Tinggi jendela prompt
titleheight=25 //Permintaan tinggi judul jendela
bordercolor="#336699";//Warna batas jendela prompt
titlecolor="#99CCFF";//Warna judul jendela prompt
var lebar, tinggi;
sWidth=dokumen.body.offsetWidth;
sTinggi=layar.tinggi;
var bgObj=dokumen.createElement("div");
bgObj.setAttribute('id','bgDiv');
bgObj.style.position="mutlak";
bgObj.style.top="0";
bgObj.style.background="#777";
bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
bgObj.style.opacity="0.6";
bgObj.style.kiri="0";
bgObj.style.width=sLebar + "px";
bgObj.style.height=sTinggi + "px";
bgObj.style.zIndex = "10000";
dokumen.body.appendChild(bgObj);
var msgObj=dokumen.createElement("div")
msgObj.setAttribute("id","msgDiv");
msgObj.setAttribute("sejajarkan","tengah");
msgObj.style.background="putih";
msgObj.style.border="1px padat " + warna batas;
msgObj.style.position = "mutlak";
msgObj.style.left = "50%";
msgObj.style.top = "50%";
msgObj.style.font="12px/1.6em Verdana, Jenewa, Arial, Helvetica, sans-serif";
msgObj.style.marginLeft = "-225px" ;
msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px";
msgObj.style.width = pesan + "px";
msgObj.style.height =msgh + "px";
msgObj.style.textAlign = "tengah";
msgObj.style.lineHeight="25px";
msgObj.style.zIndex = "10001";
var title=document.createElement("h4");
title.setAttribute("id","msgTitle");
title.setAttribute("sejajarkan","kanan");
judul.gaya.margin="0";
judul.gaya.padding="3px";
title.style.background=warna batas;
title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
judul.gaya.opacity="0.75";
title.style.border="1px solid " + warna batas;
judul.gaya.tinggi="18px";
title.style.font="12px Verdana, Jenewa, Arial, Helvetica, sans-serif";
title.style.color="putih";
title.style.cursor="penunjuk";
title.innerHTML="Tutup";
judul.onclick=function(){
dokumen.body.removeChild(bgObj);
document.getElementById("msgDiv").removeChild(judul);
document.body.removeChild(msgObj);
}
dokumen.body.appendChild(msgObj);
document.getElementById("msgDiv").appendChild(judul);
var txt=dokumen.createElement("p");
txt.style.margin="1em 0"
txt.setAttribute("id","msgTxt");
txt.innerHTML=str;
document.getElementById("msgDiv").appendChild(txt);
}