<!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></title>
</head><body>
<div style="background:#000; width:400px; height:300px;" id="col">
adasdas
</div>
<script language="javascript">
function setAlpha(Obj,opacityValue){
var Browser_Name=navigator.appName;
if (Browser_Name=="Microsoft Internet Explorer"){
Obj.style.filter="alpha(opacity="+opacityValue+")" ;
}
else{
Obj.style.opacity = opacityValue/100;
}
if (opacityValue=10000){
setTimeout(setAlpha(Obj,opacityValue+10),200);
}
}var s=document.getElementById("col");
setAlpha(s,0);
</script>
</body>
</html>现在是一进去就是黑色 没有慢慢变呢?

解决方案 »

  1.   


    <!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></title>
    </head><body>
    <div style="background:#000; width:400px; height:300px;" id="col">
    adasdas
    </div>
    <script language="javascript">
    function setAlpha(Obj,opacityValue){
    var Browser_Name=navigator.appName;
        if (Browser_Name=="Microsoft Internet Explorer"){
            Obj.style.filter="alpha(opacity="+opacityValue+")" ;
        }
        else{
         Obj.style.MozOpacity = opacityValue/100;
        }
        if (opacityValue < 100){
            setTimeout(function(){setAlpha(Obj,opacityValue+5)},100);
        }
    }var s=document.getElementById("col");
    setAlpha(s,0);
    </script>
    </body>
    </html>