听说不错的js 广告浮动
2010-01-19 10:58
399 查看
<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.jb51.net/images/logo.gif", "http://www.baidu.com");
var ad = Rimifon.NewFloatAd("http://www.jb51.net/images/logo.gif");
ad.style.left = 500;
ad.style.top = 456;
ad.Image.width = 88;
ad.Image.height = 31;
</script>
详细出处参考:/article/1261660.html
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.jb51.net/images/logo.gif", "http://www.baidu.com");
var ad = Rimifon.NewFloatAd("http://www.jb51.net/images/logo.gif");
ad.style.left = 500;
ad.style.top = 456;
ad.Image.width = 88;
ad.Image.height = 31;
</script>
详细出处参考:/article/1261660.html
相关文章推荐
- 又一个不错的js浮动广告代码
- 又一个不错的js浮动广告代码
- JS浮动广告脚本
- JS导航浮动跟踪,浮动广告,跟踪广告代码
- JS实现广告浮动
- 浮动广告js类实现
- js浮动固定层(对联飘浮广告,随滚动条浮动)
- 用js屏蔽被http劫持的浮动广告实现方法
- 网页上加上 页浮动广告的一段JS就不管用,是doctype的原因
- js实现始终浮动在一个位置的广告和页面内容禁止选中
- 建站代码====js两侧浮动广告
- js 实现网站右侧广告浮动
- js浮动广告
- 网页上加上 页浮动广告的一段JS就不管用,是doctype的原因
- Kad -- 自己写的JS浮动广告代码封装器 支持FF/IE
- 浮动广告通用JS做法
- 360浏览器的js兼容与360拦截浮动广告
- js 浮动广告
- 对联浮动广告JS代码不滚动不浮动的解决方法
- java/js 右下脚浮动小窗口,慢慢上升,类似于广告窗口