以下是 jQuery弹出广告并自动收起特效js代码 的示例演示效果:
部分效果截图:
HTML代码(index.html):
<!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=gb2312" />
<title>jQuery弹出广告并自动收起特效</title>
<style type="text/css">
.all{ width: 100%; height: 100%;color: #3d3d3d;font-size: 20px; font-family: Arial,"黑体"}
img{border:0}
</style>
<script src="js/jquery.js" type=text/javascript></script>
</head>
<body style="text-align:center">
<div class="all">
<script language=javascript src="js/topad.js" type=text/javascript></script>
<p>2秒后收起</p>
<p></p>
<p><p>伸缩前,images name:top_lanrentuku_b.jpg;伸缩后,images name:top_090901_s.gif。替换对应图片即可,推荐下载!</p></p>
<p></p>
</div>
</body>
</html>
JS代码(topad.js):
// JScript 文件function TopAd(){
var strTopAd="";
//定义小图片内容 var topSmallBanner="<div><a href=\"http://www.baidu.com/\" target=_blank><img src=\"images/top_090901_s.gif\" /></a></div>";
//判断在那些页面上显示大图变小图效果,非这些地址只显示小图(或FLASH) if (location == "http://www.baidu.com" || location == "http://www.baidu.com" || location == "http://www.baidu.com/" || true){
//定义大图内容 strTopAd="<div id=adimage style=\"width:980px\margin:0 auto\">"+ "<div id=adBig><a href=\"http://www.baidu.com/\" " + "target=_blank><img title=YUANXIN "+ "src=\"images/top_zzsc_b.jpg\" " + "border=0></A></div>"+ "<div id=adSmall style=\"display:none\">";
//strTopAd+= topFlash;
strTopAd+= topSmallBanner;
strTopAd+= "</div></div>";
}
else{
//strTopAd+=topFlash;
strTopAd+= topSmallBanner;
}
strTopAd+="<div style=\"height:7px;
clear:both;
overflow:hidden\"></div>";
return strTopAd;
}
document.write(TopAd());
$(function(){
//过两秒显示 showImage();
内容 setTimeout("showImage();
",2000);
//alert(location);
}
);
function showImage(){
$("#adBig").slideUp(1000,function(){
$("#adSmall").slideDown(1000);
}
);
}