///pc/img/blank.gif" width="12" height="8">当前位置:///default.htm" class="under">亿度网络 -> ///pc/index.htm" class="under">网页制作教程 -> JavaScript实例
///pc/homepage/javascript/sample/img/bule.gif" width="207" height="13"> ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1"> ///pc/homepage/javascript/sample/img/js.gif" width="186" height="20"> ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1">
///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1"> ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1">
     淡 出 淡 入 效 果 ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1">  
    ///pc/homepage/javascript/sample/img/bule1.gif" width="28" height="49">  
效 果 演 示 ///pc/homepage/javascript/sample/img/bule2.gif" width="11" height="18">
///pc/homepage/javascript/sample/img/1.jpg" width="300" height="233" name="child" alt="Image" style="filter:alpha(opacity=0)">    
 
源代码如下 ///pc/homepage/javascript/sample/img/bule2.gif" width="11" height="18">


这段程序放在<body>与</body>之间

   
源程序讲解: ///pc/homepage/javascript/sample/img/bule2.gif" width="11" height="18">
  ///pc/homepage/javascript/sample/img/bule1.gif" width="28" height="49">  

var b = 1;
定义变量b的值为1。
var c = true; 定义变量c为布尔型变量,值为true.
function fade() 定义一个函数,名为fade.
{ if(document.all);
if(c == true)
{ b++; }
}
当用户的浏览器是IE时,且C的值为真时,b的值累加,即b=b+1。
if(b==100)
{ b--; c = false }
如果b的值为100时,其值自减,即b=b-1,即透明度下降,且c的值为假。
f(b==10) { b++; c = true; } 如果b的值为10时,其值自加,即b=b+1,且c的值为真。
if(c == false) { b--; }
child.filters.alpha.opacity=0 + b;
且C的值为假时,b的值自减。此时,这张图的alpha(透明度)等于“0+b”的值。
setTimeout("fade()",100); 图像每100毫秒,调用一次fade函数,即透明度变化一次。可以通过调整这个数字,来控制变化的快慢。
<img src=img/1.jpg name=child style="filter:alpha(opacity=0> 插入一个文件名为“1.jpg”的图片,name=child,设置其透明度为0。

注:此例效果只能在IE中出现。图片放在与文件同级的“img”文件夹中,名为1.jpg。

  ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1">  
 

 

网页制作 网页设计 网站建设 网站设计 网站制作 做网站 做网页