Một đoạn mã để tạo hiệu ứng cửa sổ trang web rung rinh trong một thời gian ngắn trong như động đất.
HTML Code:
<SCRIPT language=JavaScript>//
hashcat@hotmail.com//change variables here
var speed = 5 //SPEED of earthquake.(less is more)
var ecount = 100 //HOW LONG the earthquake lasts.
var violence = 20 //HOW VIOLENT the earthquake is
var T = 0; //counter variable
var num_x; //X movement
var num_y; //Y movement
var positivity_x; //positivity of X movement
var positivity_y; //positivity of Y movement
//RANDOM NUMBERS FUNCTION USED FOR MOVEMENT
function randomnums() //creates two random numbers, num_x & num_y
{
positivity_x = Math.round(Math.random()); //positive or negative num_x
positivity_y = Math.round(Math.random()); //positive or negative num_y
num_x = Math.round(violence * Math.random()); //X movement
num_y = Math.round(violence * Math.random()); //Y movement
if (positivity_x == 1){ //positive or negative X
}
else
{
num_x = -num_x;
}
if (positivity_y == 1){ //positive or negative Y
}
else
{
num_y = -num_y;
}
}
//MAIN FUNCTION
function equake() {
if (T >= ecount) {stop = true}
else {
setTimeout("window.moveBy(-num_x,-num_y)", speed);
randomnums(); //MAKE FRESH RANDOM NUMS USING FUNCTION
//choose one:
http://window.resizeBy(num_x,num_y)//resize BROWSER BY (X,Y)
setTimeout("window.moveBy(num_x,num_y)", -speed);//MOVE BROWSER BY (X,Y)
http://self.scroll(num_x,num_y); //SCROLL (X,Y)
T = eval(T + 1); //add one to timer
setTimeout("equake()", speed); //speed OF EARTHQUAKE
}
}
</SCRIPT><SCRIPT language=javascript> if (confirm ("Earthquake!!!")){
equake();
window.status="EARTHQUAKE!!!!"
}
else {window.status="no earthquake
"}
</SCRIPT>__________________