new float_ad("ad_r","<img src='/System/uploads/allimg/090504/2346400.gif' />",50,false,64);

/*
漂浮广告调用
第一个参数中的url代表漂浮广告的图片URL地址(必选项),link链接到页面网址,alt图片提示文字,width图片的宽度(可选项,默认120),heihgt图片的高度(可选项,默认120)
第二个参数中的代表漂浮广告的初始位置,由参数left和top指定
第三个参数代表浮动速度,0为静止,越小浮动速度越快
*/
new move_ad({url:"/System/uploads/allimg/090504/2346400.gif",link:"https://www.jb51.net",alt:"关于招募“2009中国·大连国际樱桃节”志愿者的通知",width:200,height:200},{left:40,top:160},20);
复制代码 代码如下:
//核心代码
function $(element){
if(arguments.length>1){
for(var i=0,elements=[],length=arguments.length;i<length;i++)
elements.push($(arguments[i]));
return elements;
}
if(typeof element=="string")
return document.getElementById(element);
else
return element;
}
Function.prototype.bind=function(object){
var method=this;
return function(){
method.apply(object,arguments);
}
}
var Class={
create:function(){
return function(){
this.initialize.apply(this,arguments);
}
}
}
Object.extend=function(destination,resource){
for(var property in resource){
destination[property]=resource[property];
}
return destination;
}
//对联广告类
var float_ad=Class.create();
float_ad.prototype={
initialize:function(id,content,top,left,width){
document.write('<div id='+id+' style="position:absolute;">'+content+'</div>');
this.id=$(id);
this.top=top;
if(!!left){
this.id.style.left="8px";
}else{
this.id.style.left=(document.documentElement.clientWidth-width-8)+"px";
window.onresize=function(){
this.id.style.left=(document.documentElement.clientWidth-width-8)+"px";
}.bind(this);
}
this.id.style.top=top+"px";

this.interId=setInterval(this.scroll.bind(this),20);
},
scroll:function(){
this.stmnStartPoint = parseInt(this.id.style.top, 10);
this.stmnEndPoint =document.documentElement.scrollTop+ this.top;
if(navigator.userAgent.indexOf("Chrome")>0){
this.stmnEndPoint=document.body.scrollTop+this.top;
}
if ( this.stmnStartPoint != this.stmnEndPoint ) {
this.stmnScrollAmount = Math.ceil( Math.abs( this.stmnEndPoint - this.stmnStartPoint ) / 15 );
this.id.style.top = parseInt(this.id.style.top, 10) + ( ( this.stmnEndPoint<this.stmnStartPoint ) ? -this.stmnScrollAmount : this.stmnScrollAmount )+"px";
}
}
}
//漂浮广告类
var move_ad=Class.create();
move_ad.prototype={
initialize:function(imgOption,initPosition,delay){
this.imgOptions=Object.extend({url:"",link:"",alt:"",width:120,height:120},imgOption||{});
this.adPosition=Object.extend({left:40,top:120},initPosition||{});
this.delay =delay;
this.step = 1;
this.herizonFlag=true;
this.verticleFlag=true;
this.id="ad_move_sg";
var vHtmlString="<div id='"+this.id+"' style='position:absolute; left:"+this.adPosition.left+"px; top:"+this.adPosition.top+"px; width:"+this.imgOptions.width+"px;";
vHtmlString+=" height:"+this.imgOptions.height+"px; z-index:10;'><a href='"+this.imgOptions.link+"' target='_blank' title='"+this.imgOptions.alt+"'><img src='"+this.imgOptions.url+"' width='"+this.imgOptions.width+"' height='"+this.imgOptions.height+"' style='border:none;' alt='"+this.imgOptions.alt+"' /></a></div>";
document.write(vHtmlString);
this.id=$(this.id);
this.intervalId=setInterval(this.scroll.bind(this),this.delay);
this.id.onmouseover=this.stop.bind(this);
this.id.onmouseout=this.start.bind(this);
},
scroll:function(){
var L=T=0;
var B=document.documentElement.clientHeight-this.id.offsetHeight;
var R=document.documentElement.clientWidth-this.id.offsetWidth;
this.id.style.left=this.adPosition.left+document.documentElement.scrollLeft+"px";
this.id.style.top=this.adPosition.top+document.documentElement.scrollTop+"px";
this.adPosition.left =this.adPosition.left + this.step*(this.herizonFlag?1:-1);
if (this.adPosition.left < L) { this.herizonFlag = true; this.adPosition.left = L;}
if (this.adPosition.left > R){ this.herizonFlag = false; this.adPosition.left = R;}
this.adPosition.top =this.adPosition.top + this.step*(this.verticleFlag?1:-1);
if(this.adPosition.top <= T){ this.verticleFlag=true; this.adPosition.top=T;}
if(this.adPosition.top >= B){ this.verticleFlag=false; this.adPosition.top=B; }
},
stop:function(){
clearInterval(this.intervalId);
},
start:function(){
this.intervalId=setInterval(this.scroll.bind(this),this.delay);
}
}
标签:
js,对联广告,漂浮广告

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com

评论“js 对联广告、漂浮广告封装类(IE,FF,Opera,Safari,Chrome”

暂无“js 对联广告、漂浮广告封装类(IE,FF,Opera,Safari,Chrome”评论...

RTX 5090要首发 性能要翻倍!三星展示GDDR7显存

三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。

首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。

据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。