现在的位置: 首页 > 综合 > 正文

页面动态设置透明度

2018年06月08日 ⁄ 综合 ⁄ 共 1652字 ⁄ 字号 评论关闭

1.IE6设置透明度

    css设置

Html代码 复制代码
  1. filter:alpha(opacity=50);  

    javascript设置

Js代码 复制代码
  1. ieSpanJs.style.filter="alpha(opacity=50)";  

 

2.firefox3.5设置透明度

   firefox3.5支持css3,已经不对原来的透明度样式(-moz-opacity)提供支持(网上查的),在本人的firefox3.5.5上测试后,发现确实如此,现在的透明度设置为:

    css设置

Html代码 复制代码
  1. opacity:0.5;  

    javascript设置

Js代码 复制代码
  1. firefox35SpanJs.style.opacity="0.5";  

 

3.firefox3.5以前版本设置透明度

    css设置

Html代码 复制代码
  1. -moz-opacity:0.5;  

    javascript设置 

Js代码 复制代码
  1. firefoxSpanJs.style.mozOpacity="0.5";  

 -----------------------------------------------------------------------

function dropFadeIn_IE(target_controlid)
{
    var obj=document.getElementById(target_controlid);

    if(obj.filters.alpha.opacity<100) // In Firefox: if(obj.style.opacity<1)
    {
        obj.filters.alpha.opacity += 3;// In Firefox: obj.style.opacity =new Number(obj.style.opacity) + 0.1;
        fadeTimer1=setTimeout("dropFadeIn_IE('"+target_controlid+"')",100);
    }  
    else
    {
        clearTimeout(fadeTimer1);
        dropFadeOut_IE(target_controlid);
       
    }
}
function dropFadeOut_IE(target_controlid)
{
    var obj=document.getElementById(target_controlid);
    if(obj.filters.alpha.opacity>0)
    {

        obj.filters.alpha.opacity -= 3; // In Firefox: obj.style.opacity =new Number(obj.style.opacity) - 0.1;
        fadeTimer2=setTimeout("dropFadeOut_IE('"+target_controlid+"')",100);
    }
    else
    {
        clearTimeout(fadeTimer2);
        var imagealt=new Number(document.getElementById('img1').alt)+1;
        document.getElementById('img1').src='../../images/ad'+imagealt+'.jpg';
        dropFadeIn_IE(target_controlid);
    }
   
}

抱歉!评论已关闭.