<script>
document.getElementById('close').addEventListener('click', function () {
close();
},true)
function close(){
Rimifon.close = true;
ad.remove();
}
var Rimifon = {
"timer" : null,
"close" : false,
"Ads" : new Object,
"NewFloatAd" : function(imgUrl, strLink)
{
var ad = document.createElement("div");
ad.DirV = true;
ad.DirH = true;
ad.AutoMove = true;
ad.Image = new Image;
ad.Seed = Math.random();
ad.Timer = setInterval("Rimifon.Float(" + ad.Seed + ")", 10);
this.timer = ad.Timer;
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)
{
if(this.close){
clearInterval(this.timer);
}
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>
<script>
var ad = Rimifon.NewFloatAd("http://www.jb51.net/images/logo.gif");
ad.style.left = 500;
ad.style.top = 456;
ad.Image.width = 200;
ad.Image.height = 200;
</script>
<script>
var Rimifon = {
"Ads": new Object,
"NewFloatAd": function (imgUrl, strLink,canClose) {
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";
}
//////////////////////////////////////////
if (canClose) {
var closeA = document.createElement('a');
closeA.style.cssText = 'position:absolute;right:0;top:-20px;line-height:20px;cursor:pointer';
closeA.innerHTML = '关闭';
ad.appendChild(closeA);
ad.onclick = function () { clearInterval(ad.Timer);ad.parentNode.removeChild(ad)}
}
//////////////////////////////////////////
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>
var ad = Rimifon.NewFloatAd("http://www.jb51.net/images/logo.gif",false,true);
ad.style.left = 500;
ad.style.top = 456;
ad.Image.width = 88;
ad.Image.height = 31;
</script>
你这提问,你想说啥?? 麻烦你学习一下怎么提问好么。。。。
鬼知道你想干啥。。
把图片放在一个div层里面 实现关闭,或者图片为背景,嵌套一个小关闭按钮,实现关闭功能