一个首页顶部图片(Flash)自动下拉收缩的广告代码
在HTML页面的<head></head>中加入下面的javascript脚本:
<script type="text/javascript">
var ads_time = 500;
var ads_h = 0;
function addCount()
{
if(ads_time>0)
{
ads_time--;
ads_h = ads_h+50;
}
else
{
return;
}
if(ads_h>=330) //高度
{
return;
}
document.getElementById("ads").style.display = "";
document.getElementById("ads").style.height = ads_h+"px";
setTimeout("addCount()",30);
}
window.onload = function showAds()
{
addCount();
setTimeout("noneAds()",8000); //停留时间自己适当调整
}
</script>
<script type="text/javascript">
var ads_T = 500;
var ads_N = 330; //高度。如果高度调整不正确,可能会导致图片无法自动收缩
function noneAds()
{
if(ads_T>0)
{
ads_T--;
ads_N = ads_N-25;
}
else
{
return;
}
if(ads_N<=0)
{
document.getElementById("ads").style.display = "none";
return;
}
document.getElementById("ads").style.height = ads_N+"px";
setTimeout("noneAds()",30);
}
</script>
在<body>中插入下面的HTML代码,以显示图片(或Flash)
<!-- 下拉大幅广告 Start -->
<div id="ads" style="margin:auto; display:none; width:100%; top:0px; height:0px; position:relative; overflow:hidden; text-align:center;">
<center>
<!-- 此处就是要显示的图片(或Flash) -->
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="960" height="330">
<param name="movie" value="/images/chunjie.swf">
<param name="quality" value="high">
<param name="wmode" value="transparent">
<embed src="/images/chunjie.swf" width="960" height="330" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed>
</object>
</center><div id="close" style="position:absolute; right:50px; bottom:20px; cursor:hand;" >
<img src='ad/img/close.gif' onClick='document.getElementById("ads").style.display = "none";document.getElementById("close").style.display = "none"' width='74' height='26' border='0' vspace='3' alt='关闭广告' /></div></div>
<!-- 下拉大幅广告 End -->
posted on 2009-01-20 10:47 【好好学习天天向上】 阅读(1711) 评论(0) 收藏 举报
浙公网安备 33010602011771号