用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - javascript代码库

网页顶部自动下拉/收缩广告代码(仿京东)

2013-01-10 作者: 小蜜锋举报

[javascript]代码库

<!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" lang="gb2312">
<head>
<title>网页顶部自动下拉/收缩广告代码(仿京东)</title>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<script type="text/javascript"> 
var intervalId = null;
function slideAd(id, nStayTime, sState, nMaxHth, nMinHth)
{
    this.stayTime = nStayTime * 1000 || 3000;
    this.maxHeigth = nMaxHth || 381;
    this.minHeigth = nMinHth || 1;
    this.state = sState || "down";
    var obj = document.getElementById(id);
    if (intervalId != null)
        window.clearInterval(intervalId);
    function openBox()
    {
        var h = obj.offsetHeight;
        obj.style.height = ((this.state == "down") ? (h + 2) : (h - 2)) + "px";
        if (obj.offsetHeight > this.maxHeigth)
        {
            window.clearInterval(intervalId);
            intervalId = window.setInterval(closeBox, this.stayTime);
        }
        if (obj.offsetHeight < this.minHeigth)
        {
            window.clearInterval(intervalId);
            obj.style.display = "none";
        }
    }
    function closeBox()
    {
        slideAd(id, this.stayTime, "up", nMaxHth, nMinHth);
    }
    intervalId = window.setInterval(openBox, 10);
}
</script>
<style type="text/css">
#MyMoveAd {
	overflow:hidden;
	text-align: center;
	height: 0px;
	background-color: #AC010A;
	background-image: url(ad.jpg);
	background-repeat: no-repeat;
	background-position: center center;
	display: block;
}
</style>
</head>
<body>
<a href="#" id="MyMoveAd"> </a> 
<br>
<br>
<h1 style="text-align:center"><a href="http://yuncode.net" target="_blank">更多源代码下载</a></h1>
<script type="text/javascript"> 
 <!-- 
 slideAd('MyMoveAd',3); 
--> 
</script>
</body>
</html>

[代码运行效果截图]


网页顶部自动下拉/收缩广告代码(仿京东)

[源代码打包下载]




网友评论    (发表评论)

共2 条评论 1/1页

发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...