You can watch it later!
Copy the following blue code and save it as an html file.
The Code supports IE6, 7, 8, firefox, and Chrome browsers.
Copy codeThe Code is as follows:
<! 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 = gb2312"/>
<Title> javascript controls the transparency attribute of the Div layer, which is gradually displayed from shap to deep, and gradually disappears from deep to Shap </title>
<Script>
Var SysIsIE;
Var ua = navigator. userAgent. toLowerCase ();
Var s; (s = ua. match (/msie ([\ d.] + )/))? SysIsIE = s [1]: 0;
Function Q (s ){
Return document. getElementById (s );
}
Function dvck (){
Idstr = 'tiany ';
E = Q (idstr );
If (e ){
E. parentNode. removeChild (e );
}
Var div = document. createElement ("div ");
Div. style. position = "absolute ";
Div. style. top = '123 ';
Div. style. left = '123 ';
Div.style.css Text = 'filter: alpha (opacity = 10); opacity: 0.1; position: absolute; top: 50%; left: 50%; width: 544px; height: 354px; margin-top:-177px; margin-left:-272px; background-color: #000 ';
Div. id = idstr;
// Div. innerHTML = ' ';
Div. innerHTML = '<p style = "color: # fff; text-align: center;"> div layer display content, author: <a href = "http://hi.baidu.com/bluid" style = "color: # FBFC4D "> bluid </a> <br> <a href =" javascript: cleand (\ ''+ idstr + '\')" style = "color: # FEF8C3"> close </a> </p> ';
Document. body. appendChild (div );
If (SysIsIE)
DcbIE (idstr, '+ ');
Else
Dcboth (idstr, '+ ');
}
Function dcbIE (s, j ){
O = Q (s );
Opc = parseInt (o. filters. alpha. opacity );
If (j = '+ '){
If (opc <100 ){
O. filters. alpha. opacity = (opc + 10) + '';
SetTimeout ("dcbIE ('" + s + "', '" + j + "')", 100 );
}
} Else if (j = '-'){
If (opc> 0 ){
O. filters. alpha. opacity = (opc-10) + '';
SetTimeout ("cleand ('" + s + "', '" + j + "')", 100 );
}
}
}
Function dcboth (s, j ){
O = Q (s );
Opc = parseFloat (o. style. opacity );
If (j = '+ '){
If (opc <1 ){
O. style. opacity = (opc + 0.1) + '';
// SetInterval ("dcboth ('" + s + "')", 3000 );
SetTimeout ("dcboth ('" + s + "', '" + j + "')", 100 );
}
} Else if (j = '-'){
If (opc> 0 ){
O. style. opacity = (opc-0.1) + '';
SetTimeout ("cleand ('" + s + "', '" + j + "')", 100 );
}
}
}
Function cleand (s ){
If (SysIsIE ){
DcbIE (s ,'-');
} Else {
Dcboth (s ,'-');
}
}
</Script>
</Head>
<Body>
<Div> <br>
<P style = "font-size: 14px"> javascript controls the transparency attribute of the Div layer, which is gradually displayed from shap to deep, and gradually disappears from deep to shap. </p> <br>
<Br>
<P> click 'click' to display the layer gradually from shortest to deep </p> <br>
<A href = "javascript: dvck ()"> click </a> <br>
<P> click on the displayed layer to gradually disappear from deep to light </p>
<Br>
<P>
<! -- # BeginDate format: Am3m --> 02/11/2011 16:17 <! -- # EndDate --> --- author: <a href = "http://hi.baidu.com/bluid"> bluid </a>
</P>
<Br>
<Br>
</Div>
</Body>
</Html>