滑鼠停留圖片從黑白到彩色漸變
作者:tank 日期:2007-08-20
代碼如下:
<style>
.gray{
filter:progid:DXImageTransform.Microsoft.Fade(duration=1);zoom:1;
}
.gray img{
filter:gray();
}
</style>
<script type="text/javascript">
function initGray(){
for(var i=0,c=document.getElementsByTagName('span');i<c.length;i++)
if(c[i].className=='gray'&&c[i].getElementsByTagName('img').length==1){
c[i].onmouseenter=function(){doTrans(this,false);};
c[i].onmouseleave=function(){doTrans(this,true);};
}
function doTrans(ele,bgray){
ele.filters[0].apply();
ele.getElementsByTagName('img')[0].filters[0].enabled=bgray;
ele.filters[0].play();
}
}
if(window.attachEvent)
window.attachEvent('onload',initGray);
</script>
<span class=gray>
<a href="http://blog.tank.tw/">
<img border="0" src="/UploadFiles/2007-8/202341940080.jpg" />
</a>
</span>