页面导航: 首页网络编程JavaScript广告代码 → 正文内容

又一个不错的js浮动广告代码

发布:dxy 字体:[增加 减小] 类型:转载
<script>
var Rimifon = {
    "Ads" : new Object,
    "NewFloatAd" : function(imgUrl, strLink)
    {
        var ad = document.createElement("a");
        ad.DirV = true;
        ad.DirH = true;
        ad.AutoMove = true;
        ad.Image = new Image;
        ad.Seed = Math.random();
        ad.Timer = setInterval("Rimifon.Float(" + ad.Seed + ")", 50);
        this.Ads[ad.Seed] = ad;
        ad.Image.Parent = ad;
        ad.style.position = "absolute";
        ad.style.left = 0;
        ad.style.top = 0;
        ad.Image.src = imgUrl;
        ad.Image.onmouseover = function(){this.Parent.AutoMove = false;}
        ad.Image.onmouseout = function(){this.Parent.AutoMove = true;}
        if(strLink)
        {
            ad.href = strLink;
            ad.Image.border = 0;
            ad.target = "_blank";
        }
        ad.appendChild(ad.Image);
        document.body.appendChild(ad);
        return ad;
    },
    "Float" : function(floatId)
    {
        var ad = this.Ads[floatId];
        if(ad.AutoMove)
        {
            var curLeft = parseInt(ad.style.left);
            var curTop = parseInt(ad.style.top);
            if(ad.offsetWidth + curLeft > document.body.clientWidth + document.body.scrollLeft - 1)
            {
                curLeft = document.body.scrollLeft + document.body.clientWidth - ad.offsetWidth;
                ad.DirH = false;
            }
            if(ad.offsetHeight + curTop > document.body.clientHeight + document.body.scrollTop - 1)
            {
                curTop = document.body.scrollTop + document.body.clientHeight - ad.offsetHeight;
                ad.DirV = false;
            }
            if(curLeft < document.body.scrollLeft)
            {
                curLeft = document.body.scrollLeft;
                ad.DirH = true;
            }
            if(curTop < document.body.scrollTop)
            {
                curTop = document.body.scrollTop;
                ad.DirV = true;
            }
            ad.style.left = curLeft + (ad.DirH ? 1 : -1) + "px";
            ad.style.top = curTop + (ad.DirV ? 1 : -1) + "px";
        }
    }
}
</script><body><div style="width:30cm;height:40cm"></div></body><script>
Rimifon.NewFloatAd("http://www.zope.org/Members/Rimifon/NetDisk/FileStore/1147882113969.gif", "http://www.baidu.com");
var ad = Rimifon.NewFloatAd("http://www.fengyun.org/Images/Logo.jpg");
ad.style.left = 500;
ad.style.top = 456;
ad.Image.width = 88;
ad.Image.height = 31;
</script>
百度中搜索更多的关于又一个不错的js浮动广告代码内容,或者用Google搜索相关更多
浏览次数:载入中... 打印本文关闭本文返回首页

文章评论

共有 位脚本之家网友发表了评论我来说两句

同 类 文 章
最 近 更 新
热 点 排 行