/* * 浮动广告插件 * */ function eipfloatad(settings){ this.positionid = settings.positionid //广告位id this.paddingleft =(typeof settings.paddingleft === 'number')?settings.paddingleft:0; //左内边距 起始位置 this.paddingtop = (typeof settings.paddingtop === 'number')?settings.paddingtop:0; //上内边距 超始位置 this.width = (typeof settings.width === 'number')?settings.width:100; //广告位宽 this.height =(typeof settings.height === 'number')?settings.height:100; //广告位高 this.step =(typeof settings.step === 'number')?settings.step:1; //默认为1 this.delay = (typeof settings.delay === 'number')?settings.delay:20;//默认为20; this.windowheight = (typeof settings.windowheight === 'number')?settings.windowheight:0;//默认为0 this.windowwidth = (typeof settings.windowwidth === 'number')?settings.windowwidth:0;//默认为0 this.yon = (typeof settings.yon === 'number')?settings.yon:0; //默认为0 this.xon = (typeof settings.xon === 'number')?settings.xon:0; //默认为0 this.pause = true; //暂停状态 this.interval = null; this.syspath=(settings.syspath===null)?"/":settings.syspath;//默认为"/" this.siteid=(typeof settings.siteid === 'number')?settings.siteid:0; // 默认为0 this.url=(settings.url===null)?"/adclick.aspx":settings.url; /* * adid: 广告id * title:广告标题 * linkurl:广告链接地址 * imageurl:广告图片或flash路径 * adtype:广告类型(image或flash) */ this.adcontent=settings.adcontent; //广告内容 return this; }; /* * 启动 */ eipfloatad.prototype.start=function(){ var self=this; console.log(self.paddingleft); function showadcontent() { // alert(self.adcontent); var str = "
"; var json = self.adcontent; for(var i=0;i"; str += ""; str += ""; } else if (self.adcontent[i].adtype == "flash") { document.write(" ");//至少要输出一个字,不然ie不显示 str += ""; str += ""; str += ""; str += ""; str += ""; str += ""; } } // alert(str); str += "
关闭
"; str += "
"; document.write(str); } function changepos(float) { float.windowwidth = document.documentelement.clientwidth; float.windowheight = document.documentelement.clientheight; document.getelementbyid("zcmsad_" + float.positionid).style.left = (float.paddingleft + document.documentelement.scrollleft) + "px"; document.getelementbyid("zcmsad_" + float.positionid).style.top = (float.paddingtop + document.documentelement.scrolltop) + "px"; if (float.yon) { float.paddingtop = float.paddingtop + float.step; } else { float.paddingtop = float.paddingtop - float.step; } if (float.paddingtop < 0) { float.yon = 1; float.paddingtop = 0; } if (float.paddingtop >= (float.windowheight - float.height)) { float.yon = 0; float.paddingtop = (float.windowheight - float.height); } if (float.xon) { float.paddingleft = float.paddingleft + float.step; } else { float.paddingleft = float.paddingleft - float.step; } if (float.paddingleft < 0) { float.xon = 1; float.paddingleft = 0; } if (float.paddingleft >= (float.windowwidth - float.width)) { float.xon = 0; float.paddingleft = (float.windowwidth - float.width); } } function dostart(float) { return function() { changepos(float); } } function pause(float) { if (float.pause) { clearinterval(float.interval); float.pause = false; } else { float.interval = setinterval(dostart(float), float.delay); float.pause = true; } } showadcontent(); //dostart(self); self.interval = setinterval(dostart(self), self.delay); $("#zcmsad_"+self.positionid).on("mouseover",function(){ pause(self); }); $("#zcmsad_"+self.positionid).on("mouseout",function(){ pause(self); }); return self; };