为什么随屏移动的关闭不起作用?
时间:2010-05-17
来源:互联网
随屏移动代码如下,用的是动易广告自带的JS模板,之前是不带关闭的,参考它的对联广告的关闭,增加了关闭按钮,但是不起作用,下边代码中红色部分为增加的代码:
function ObjectAD() {
/* Define Variables*/
this.ADID = 0;
this.ADType = 0;
this.ADName = "";
this.ImgUrl = "";
this.ImgWidth = 0;
this.ImgHeight = 0;
this.FlashWmode = 0;
this.LinkUrl = "";
this.LinkTarget = 0;
this.LinkAlt = "";
this.Priority = 0;
this.CountView = 0;
this.CountClick = 0;
this.InstallDir = "";
this.ADDIR = "";
}
function MoveZoneAD(_id) {
/* Define Common Variables*/
this.ID = _id;
this.ZoneID = 0;
this.ZoneName = "";
this.ZoneWidth = 0;
this.ZoneHeight = 0;
this.ShowType = 1;
this.DivName = "";
this.Div = null;
/* Define Unique Variables*/
this.Left = 0;
this.Top = 0;
this.Delta = 0.15;
/* Define Objects */
this.AllAD = new Array();
this.ShowAD = null;
/* Define Functions */
this.AddAD = MoveZoneAD_AddAD;
this.GetShowAD = MoveZoneAD_GetShowAD;
this.Show = MoveZoneAD_Show;
this.Move = MoveZoneAD_Move;
}
function MoveZoneAD_AddAD(_AD) {
this.AllAD[this.AllAD.length] = _AD;
}
function MoveZoneAD_GetShowAD() {
if (this.ShowType > 1) {
this.ShowAD = this.AllAD[0];
return;
}
var num = this.AllAD.length;
var sum = 0;
for (var i = 0; i < num; i++) {
sum = sum + this.AllAD[i].Priority;
}
if (sum <= 0) {return ;}
var rndNum = Math.random() * sum;
i = 0;
j = 0;
while (true) {
j = j + this.AllAD[i].Priority;
if (j >= rndNum) {break;}
i++;
}
this.ShowAD = this.AllAD[i];
}
function MoveZoneAD_Show() {
if (!this.AllAD) {
return;
} else {
this.GetShowAD();
}
if (this.ShowAD == null) return false;
this.DivName = "MoveZoneAD_Div" + this.ZoneID;
if (!this.ShowAD.ImgWidth) this.ShowAD.ImgWidth = this.ZoneWidth
if (!this.ShowAD.ImgHeight) this.ShowAD.ImgHeight = this.ZoneHeight
if (this.ShowAD.ADDIR=="") this.ShowAD.ADDIR = "AD"
document.write("<div id='" + this.DivName + "' style='position:absolute; visibility:visible; z-index:1; width:" + this.ZoneWidth + "px; height:" + this.ZoneHeight + "px; left:" + this.Left + "px;top:" + this.Top + "px'>" + AD_Content(this.ShowAD)+ "<div style='cursor
ointer;float:left;text-align:right;width:" + this.ZoneWidth + "px;height:20px;' onclick='javascript:document.getElementById(\"" + this.DivName + "\").style.display = \"none\";'>×关闭</div></div>");
if (this.ShowAD.CountView) {
document.write ("<script src='" + this.ShowAD.InstallDir + this.ShowAD.ADDIR + "/ADCount.asp?Action=View&ADID=" + this.ShowAD.ADID + "'></script>")
}
this.Div = document.getElementById(this.DivName);
setInterval(this.ID + ".Move()", 10);
}
function MoveZoneAD_Move() {
if(document.all) {
pageX=document.body.scrollLeft;
pageY=document.body.scrollTop;
}
else {
pageX=window.pageXOffset;
pageY=window.pageYOffset;
}
if (this.Div.offsetLeft != (pageX + this.Left)) {
var dx = (pageX + this.Left - this.Div.offsetLeft) * this.Delta;
dx = (dx > 0 ? 1 : - 1) * Math.ceil(Math.abs(dx));
this.Div.style.left = this.Div.offsetLeft + dx + "px";
}
if (this.Div.offsetTop != (pageY + this.Top)) {
var dy = (pageY + this.Top - this.Div.offsetTop) * this.Delta;
dy = (dy > 0 ? 1 : - 1) * Math.ceil(Math.abs(dy));
this.Div.style.top = this.Div.offsetTop + dy + "px";
}
this.Div.style.display = '';
}
function AD_Content(o) {
var str = "";
if (o.ADType == 1 || o.ADType == 2) {
imgurl = o.ImgUrl .toLowerCase()
if (o.InstallDir.indexOf("http://") != - 1) imgurl = o.InstallDir.substr(0, o.InstallDir.length - 1) + imgurl;
if (imgurl.indexOf(".swf") != - 1) {
str = "<object classid='clsid
27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0'";
str += " name='AD_" + o.ADID + "' id='AD_" + o.ADID + "'";
str += " width='" + o.ImgWidth + "px'";
str += " height='" + o.ImgHeight + "px'";
if (o.style) str += " style='" + o.style + "'";
if (o.extfunc) str += " " + o.extfunc + " ";
str += ">";
str += "<param name='movie' value='" + imgurl + "'>";
if (o.FlashWmode == 1) str += "<param name='wmode' value='Transparent'>";
if (o.play) str += "<param name='play' value='" + o.play + "'>";
if (typeof(o.loop) != "undefined") str += "<param name='loop' value='" + o.loop + "'>";
str += "<param name='quality' value='autohigh'>";
str += "<embed ";
str += " name='AD_" + o.ADID + "' id='AD_" + o.ADID + "'";
str += " width='" + o.ImgWidth + "px'";
str += " height='" + o.ImgHeight + "px'";
if (o.style) str += " style='" + o.style + "'";
if (o.extfunc) str += " " + o.extfunc + " ";
str += " src='" + imgurl + "'";
if (o.FlashWmode == 1) str += " wmode='Transparent'";
if (o.play) str += " play='" + o.play + "'";
if (typeof(o.loop) != "undefined") str += " loop='" + o.loop + "'";
str += " quality='autohigh'"
str += " pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash'></embed>";
str += "</object>";
} else if (imgurl.indexOf(".gif") != - 1 || imgurl.indexOf(".jpg") != - 1 || imgurl.indexOf(".jpeg") != - 1 || imgurl.indexOf(".bmp") != - 1 || imgurl.indexOf(".png") != - 1) {
if (o.LinkUrl) {
if (o.CountClick) o.LinkUrl = o.InstallDir + o.ADDIR + "/ADCount.asp?Action=Click&ADID=" + o.ADID
str += "<a href='" + o.LinkUrl + "' target='" + ((o.LinkTarget == 0) ? "_self" : "_blank") + "' title='" + o.LinkAlt + "'>";
}
str += "<img ";
str += " name='AD_" + o.ADID + "' id='AD_" + o.ADID + "'";
if (o.style) str += " style='" + o.style + "'";
if (o.extfunc) str += " " + o.extfunc + " ";
str += " src='" + imgurl + "'";
if (o.ImgWidth) str += " width='" + o.ImgWidth + "px'";
if (o.ImgHeight) str += " height='" + o.ImgHeight + "px'";
str += " border='0'>";
if (o.LinkUrl) str += "</a>";
}
} else if (o.ADType == 3 || o.ADType == 4) {
str = o.ADIntro
} else if (o.ADType == 5) {
str = "<iframe id='" + "AD_" + o.ADID + "' marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no width=100% height=100% src='" + o.ADIntro + "'>wait</iframe>";
}
return str;
}
没有增加关闭之前的代码如下:
。。。。
document.write("<div id='" + this.DivName + "' style='position:absolute; visibility:visible; z-index:1; width:" + this.ZoneWidth + "px; height:" + this.ZoneHeight + "px; left:" + this.Left + "px;top:" + this.Top + "px'>" + AD_Content(this.ShowAD)+ "</div>");
。。。。
[ 本帖最后由 batistutafans 于 2010-5-17 17:01 编辑 ]
function ObjectAD() {
/* Define Variables*/
this.ADID = 0;
this.ADType = 0;
this.ADName = "";
this.ImgUrl = "";
this.ImgWidth = 0;
this.ImgHeight = 0;
this.FlashWmode = 0;
this.LinkUrl = "";
this.LinkTarget = 0;
this.LinkAlt = "";
this.Priority = 0;
this.CountView = 0;
this.CountClick = 0;
this.InstallDir = "";
this.ADDIR = "";
}
function MoveZoneAD(_id) {
/* Define Common Variables*/
this.ID = _id;
this.ZoneID = 0;
this.ZoneName = "";
this.ZoneWidth = 0;
this.ZoneHeight = 0;
this.ShowType = 1;
this.DivName = "";
this.Div = null;
/* Define Unique Variables*/
this.Left = 0;
this.Top = 0;
this.Delta = 0.15;
/* Define Objects */
this.AllAD = new Array();
this.ShowAD = null;
/* Define Functions */
this.AddAD = MoveZoneAD_AddAD;
this.GetShowAD = MoveZoneAD_GetShowAD;
this.Show = MoveZoneAD_Show;
this.Move = MoveZoneAD_Move;
}
function MoveZoneAD_AddAD(_AD) {
this.AllAD[this.AllAD.length] = _AD;
}
function MoveZoneAD_GetShowAD() {
if (this.ShowType > 1) {
this.ShowAD = this.AllAD[0];
return;
}
var num = this.AllAD.length;
var sum = 0;
for (var i = 0; i < num; i++) {
sum = sum + this.AllAD[i].Priority;
}
if (sum <= 0) {return ;}
var rndNum = Math.random() * sum;
i = 0;
j = 0;
while (true) {
j = j + this.AllAD[i].Priority;
if (j >= rndNum) {break;}
i++;
}
this.ShowAD = this.AllAD[i];
}
function MoveZoneAD_Show() {
if (!this.AllAD) {
return;
} else {
this.GetShowAD();
}
if (this.ShowAD == null) return false;
this.DivName = "MoveZoneAD_Div" + this.ZoneID;
if (!this.ShowAD.ImgWidth) this.ShowAD.ImgWidth = this.ZoneWidth
if (!this.ShowAD.ImgHeight) this.ShowAD.ImgHeight = this.ZoneHeight
if (this.ShowAD.ADDIR=="") this.ShowAD.ADDIR = "AD"
document.write("<div id='" + this.DivName + "' style='position:absolute; visibility:visible; z-index:1; width:" + this.ZoneWidth + "px; height:" + this.ZoneHeight + "px; left:" + this.Left + "px;top:" + this.Top + "px'>" + AD_Content(this.ShowAD)+ "<div style='cursor

if (this.ShowAD.CountView) {
document.write ("<script src='" + this.ShowAD.InstallDir + this.ShowAD.ADDIR + "/ADCount.asp?Action=View&ADID=" + this.ShowAD.ADID + "'></script>")
}
this.Div = document.getElementById(this.DivName);
setInterval(this.ID + ".Move()", 10);
}
function MoveZoneAD_Move() {
if(document.all) {
pageX=document.body.scrollLeft;
pageY=document.body.scrollTop;
}
else {
pageX=window.pageXOffset;
pageY=window.pageYOffset;
}
if (this.Div.offsetLeft != (pageX + this.Left)) {
var dx = (pageX + this.Left - this.Div.offsetLeft) * this.Delta;
dx = (dx > 0 ? 1 : - 1) * Math.ceil(Math.abs(dx));
this.Div.style.left = this.Div.offsetLeft + dx + "px";
}
if (this.Div.offsetTop != (pageY + this.Top)) {
var dy = (pageY + this.Top - this.Div.offsetTop) * this.Delta;
dy = (dy > 0 ? 1 : - 1) * Math.ceil(Math.abs(dy));
this.Div.style.top = this.Div.offsetTop + dy + "px";
}
this.Div.style.display = '';
}
function AD_Content(o) {
var str = "";
if (o.ADType == 1 || o.ADType == 2) {
imgurl = o.ImgUrl .toLowerCase()
if (o.InstallDir.indexOf("http://") != - 1) imgurl = o.InstallDir.substr(0, o.InstallDir.length - 1) + imgurl;
if (imgurl.indexOf(".swf") != - 1) {
str = "<object classid='clsid

str += " name='AD_" + o.ADID + "' id='AD_" + o.ADID + "'";
str += " width='" + o.ImgWidth + "px'";
str += " height='" + o.ImgHeight + "px'";
if (o.style) str += " style='" + o.style + "'";
if (o.extfunc) str += " " + o.extfunc + " ";
str += ">";
str += "<param name='movie' value='" + imgurl + "'>";
if (o.FlashWmode == 1) str += "<param name='wmode' value='Transparent'>";
if (o.play) str += "<param name='play' value='" + o.play + "'>";
if (typeof(o.loop) != "undefined") str += "<param name='loop' value='" + o.loop + "'>";
str += "<param name='quality' value='autohigh'>";
str += "<embed ";
str += " name='AD_" + o.ADID + "' id='AD_" + o.ADID + "'";
str += " width='" + o.ImgWidth + "px'";
str += " height='" + o.ImgHeight + "px'";
if (o.style) str += " style='" + o.style + "'";
if (o.extfunc) str += " " + o.extfunc + " ";
str += " src='" + imgurl + "'";
if (o.FlashWmode == 1) str += " wmode='Transparent'";
if (o.play) str += " play='" + o.play + "'";
if (typeof(o.loop) != "undefined") str += " loop='" + o.loop + "'";
str += " quality='autohigh'"
str += " pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash'></embed>";
str += "</object>";
} else if (imgurl.indexOf(".gif") != - 1 || imgurl.indexOf(".jpg") != - 1 || imgurl.indexOf(".jpeg") != - 1 || imgurl.indexOf(".bmp") != - 1 || imgurl.indexOf(".png") != - 1) {
if (o.LinkUrl) {
if (o.CountClick) o.LinkUrl = o.InstallDir + o.ADDIR + "/ADCount.asp?Action=Click&ADID=" + o.ADID
str += "<a href='" + o.LinkUrl + "' target='" + ((o.LinkTarget == 0) ? "_self" : "_blank") + "' title='" + o.LinkAlt + "'>";
}
str += "<img ";
str += " name='AD_" + o.ADID + "' id='AD_" + o.ADID + "'";
if (o.style) str += " style='" + o.style + "'";
if (o.extfunc) str += " " + o.extfunc + " ";
str += " src='" + imgurl + "'";
if (o.ImgWidth) str += " width='" + o.ImgWidth + "px'";
if (o.ImgHeight) str += " height='" + o.ImgHeight + "px'";
str += " border='0'>";
if (o.LinkUrl) str += "</a>";
}
} else if (o.ADType == 3 || o.ADType == 4) {
str = o.ADIntro
} else if (o.ADType == 5) {
str = "<iframe id='" + "AD_" + o.ADID + "' marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no width=100% height=100% src='" + o.ADIntro + "'>wait</iframe>";
}
return str;
}
没有增加关闭之前的代码如下:
。。。。
document.write("<div id='" + this.DivName + "' style='position:absolute; visibility:visible; z-index:1; width:" + this.ZoneWidth + "px; height:" + this.ZoneHeight + "px; left:" + this.Left + "px;top:" + this.Top + "px'>" + AD_Content(this.ShowAD)+ "</div>");
。。。。
[ 本帖最后由 batistutafans 于 2010-5-17 17:01 编辑 ]
作者: batistutafans 发布时间: 2010-05-17
请高手指点一下,为什么关闭不起作用呢?
作者: batistutafans 发布时间: 2010-05-18
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28