js 漂浮广告 四周来回漂
2009-12-08 11:14
169 查看
<html>
<head>
<title>特效</title>
<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://gkb.com.cn/Images/11.jpg", "http://www.baidu.com");
</script>
</head>
<body>
</body>
</html>
<head>
<title>特效</title>
<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://gkb.com.cn/Images/11.jpg", "http://www.baidu.com");
</script>
</head>
<body>
</body>
</html>
相关文章推荐
- js 对联广告、漂浮广告封装类(IE,FF,Opera,Safari,Chrome
- JS随机漂浮广告代码
- 不用js多浏览器兼容纯DIV/CSS对联漂浮广告代码
- JS带关闭按钮的网页漂浮广告代码
- js 漂浮广告 从上往下最后消失
- 网页特效”漂浮广告代码”来回跳动的
- 网页特效”漂浮广告代码”来回跳动的
- 非常不错的漂浮广告代码(须调用外部JS文件)
- JS随机漂浮广告代码具体实例
- 漂浮广告的JS代码(经典)
- JS上下自动漂浮广告,可关闭
- 右下角弹出广告 js,漂浮效果(兼容多浏览器)
- js漂浮广告代码(简洁!)
- 兼容的漂浮广告(js)
- 基于JQuery网页漂浮广告窗口Js详解
- JS漂浮广告代码
- js实现广告漂浮效果的小例子
- 兼容性非常好的js右下角与漂浮广告代码
- js实现全屏漂浮广告移入光标停止移动
- js右下角与漂浮广告代码(兼容多浏览器)