Javascript controls the transparency attribute of the Div layer from the shap to gradually display _ javascript tips

Source: Internet
Author: User
Control the transparent properties of the Div layer, gradually display from shap to deep, and gradually disappear from deep to shap. The specific implementation code is as follows. If you like it, you can feel it and keep it for yourself!

Copy the following blue code and save it as an html file.

The Code supports IE6, 7, 8, firefox, and Chrome browsers.

The Code is as follows:






Javascript controls the transparent attributes of the Div layer, and gradually displays the transparent attributes from shap to deep, gradually disappears from deep to shap.
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 p = document. createElement ("p ");
P. style. position = "absolute ";
P. style. top = '123 ';
P. style. left = '20140901 ';
P.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 ';
P. id = idstr;
// P. innerHTML = '';
P. innerHTML ='

Content displayed on the p layer, author: bluid




Close

';
Document. body. appendChild (p );
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





Javascript controls the transparent attributes of the Div layer, and gradually displays the transparent attributes from shallow to deep, and gradually disappears from deep to light.








Click 'click' to display the layer.






Click




Click on the displayed layer to gradually disappear from deep to light







02/11/2011 16: 17 --- Author: bluid












Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.