Mã sử dụng:
- Code:
[notnhac][/notnhac]
- Code:
<!--
var num=8
var x=-50,y=-50
var count
for (i=0;i<num;i++){
with (document)
{
if(document.all)
{
write( "<div id='note"+i+"' style='position:absolute;left:"+x+"; top: "+y +";'>")
write("<img src='http://quangnhut.bizhat.com/forum/icon.gif' border=0>")
document.write("</div>")
}
else if(document.layers)
{
write( "<layer id='"+"note"+i+"' left="+x+" top="+y +">")
write("<img src='http://loitraitim.com/images/icon.gif' border=0>")
document.write("</layer>")
}
}
}
window.document.onclick=playSound;
if(document.all)
{
window.document.onmousedown= updatePos;
}
else if(document.layers)
{
window.captureEvents(Event.MOUSEDOWN)
onMouseDown=updatePos
}
function updatePos(e)
{
if(document.all)
{
x =event.clientX+document.body.scrollLeft;
y =event.clientY+document.body.scrollTop;
}
else if(document.layers)
{
x =e.pageX
y =e.pageY
}
}
function playSound()
{
count=0
animation()
}
function animation(){
if(document.all)
{
if(count<5)
{
for(i=0;i<num;i++)
{
document.all["note"+i].style.left=x+Math.sin(i*Math.PI*2/num)*20*count
document.all["note"+i].style.top=y+Math.cos(i*Math.PI*2/num)*20*count
}
setTimeout('animation()',50)
}
else
{
for(i=0;i<num;i++)
{
document.all["note"+i].style.left=-50
document.all["note"+i].style.top=-50
}
}
}
else if(document.layers)
{
if(count<5)
{
for(i=0;i<num;i++)
{
document.layers[i].left=x+Math.sin(i*Math.PI*2/num)*20*count
document.layers[i].top=y+Math.cos(i*Math.PI*2/num)*20*count
}
setTimeout('animation()',50)
}
else
{
for(i=0;i<num;i++){
document.layers[i].left=-50
document.layers[i].top=-50
}
}
}
count++;
}
//-->