日期:2014-05-16  浏览次数:20379 次

js让图片从上慢慢消失,再换张图片慢慢显示
<!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>js让图片从上慢慢消失,再换张图片慢慢显示</title>
<script language="javascript" type="text/javascript">
window.onload = function(){
    var fudongAD = document.getElementById("headads");
	setTimeout("noneheadads()", 1000); //停留时间自己适当调整

}

var height2 = 339; //高度
function noneheadads() {
    height2 = height2 - 10;
    if (height2 <= 0) {
        document.getElementById("headads").style.display = "none";
		setTimeout("showheadads()", 1000);
        return;
    }

    document.getElementById("headads").style.height = height2 + "px";
    setTimeout("noneheadads()", 40);
}

var height3 = 0; //高度
function showheadads(){
		 height3 = height3 + 10;
		  if (height3 >= 300) {
        document.getElementById("headads2").style.height = height3 + "px";
        return;
    }
	document.getElementById("headads2").style.height = height3 + "px";
	document.getElementById("headads2").style.display = "";
    setTimeout("showheadads()", 40);
}
</script>
</head>

<body>
<div id="headads" style="margin: 0 auto; overflow:hidden;"><img src="http://www.sosuo8.com/article/upimages3/112_jpg_thumb.jpg" /></div>
<div id="headads2" style="display:none;margin: 0 auto; overflow:hidden;"><img src="cwyg201120101.jpg" /></div>
</body>
</html>