js 全屏移动漂浮框广告栏(3w)

<body>
<div style="width:30cm;height:40cm">asdf</div>
</body> 

<script> 

var str = "最新风险提示:"
var countWords = str +"骗取国家补贴,弄虚作假终被判";
var Rimifon = { 
"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 + ")", 50); 
this.Ads[ad.Seed] = ad; 
ad.Image.Parent = ad; 
ad.style.position = "fixed"; 
ad.style.left = 0; 
ad.style.top = 0; 
ad.Image.src = imgUrl; 


ad.onmouseover = function(){this.AutoMove = false;} 
ad.onmouseout = function(){this.AutoMove = true;}


var close = document.createElement("a");
close.setAttribute("class", "closedd"); 
ad.setAttribute("class", "closed_box"); 
var countMessage = document.createElement('p');
countMessage.setAttribute("class",'jsMessage');
countMessage.append(countWords);
if(strLink) 

ad.href = strLink; 
ad.Image.border = 0; 
ad.target = "_blank"; 

ad.appendChild(ad.Image); 
ad.appendChild(close); 
ad.appendChild(countMessage);
close.append('x'); 
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.documentElement.clientWidth + document.body.scrollLeft - 1) 

curLeft = document.body.scrollLeft + document.documentElement.clientWidth - ad.offsetWidth; 
ad.DirH = false; 

if(ad.offsetHeight + curTop > document.documentElement.clientHeight + document.body.scrollTop - 1) 

curTop = document.body.scrollTop + document.documentElement.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 ? 3 : - 3) + "px"; 
ad.style.top = curTop + (ad.DirV ? 3 : - 3) + "px"; 



</script>
<script> 
//Rimifon.NewFloatAd("http://www.jb51.net/images/logo.gif", "http://www.baidu.com"); 
var ad = Rimifon.NewFloatAd("../images/banben2/point.png"); 
ad.style.left = 500; 
ad.style.top = 456; 
//ad.Image.width = 498; 
//ad.Image.height = 70; 


$(".closedd").on("click",function(){
$(this).closest("div").remove();
})
</script> 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值