<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> ad shrinking effect on the 163 homepage </title>
<Style>
# Top {
Position: relative;
}
# Content {
Position: absolute;
}
</Style>
</Head>
<Body onload = "moveDown ()" style = "margin: 0px; 0px;">
<Div id = "top" style = "width: 100%; height: 100px; background-color: # F96"> webpage advertisement <br>
Webpage advertisement <br>
Webpage advertisement <br>
Webpage advertisement <br>
Webpage advertisement <br>
Webpage advertisement <br>
Webpage advertisement <br>
Webpage advertisement <br>
Webpage advertisement <br>
Webpage advertisement <br>
Webpage advertisement <br>
Webpage advertisement <br>
Webpage advertisement <br>
Webpage advertisement <br>
Webpage advertisement <br>
Webpage advertisement <br>
Webpage advertisement <br>
</Div>
<Div id = "content" style = "width: 100%; height: 500px; background-color: # FF9"> This is the body of the webpage </div>
</Body>
</Html>
<Script language = "javascript" type = "text/javascript">
// Define the distance to be moved
Var h = 0;
Var maxheight = 300;
Var st;
Var top = document. getElementById ("top ");
// Initially, set top to hidden.
Top. style. display = "none ";
// Define to expand the advertisement part
Function moveDown (){
// Accumulate
H + = 2;
// Set the height to the value we accumulate
Top. style. height = h;
// Set the layer display
Top. style. display = "block ";
// Determine whether the maximum value is reached
If (h <= maxheight ){
St = setTimeout ("moveDown ()", 50 );
} Else {
ClearTimeout (st );
// Delay 3 seconds and start to contract
SetTimeout ("moveUp ()", 3000 );
}
}
// Define to shrink the advertisement part
Function moveUp (){
// Set
H-= 2;
// Set the height to the value we accumulate
Top. style. height = h;
// Set the layer display
Top. style. display = "block ";
If (h <= 0 ){
Top. style. display = "none ";
// Clear the timer
ClearTimeout (st );
} Else {
// If h> 0, continue to contract
St = setTimeout ("moveUp ()", 50 );
}
}
</Script>
From the column by Liu haicao