如何修改js代码,增加左侧的弹出广告 请问怎么给右下角js广告代码增加关闭按钮?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>不会被屏蔽的网页右下角漂浮窗口代码</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312" />
<style type="text/css">
#msg_win{border:1px solid #A67901;background:#EAEAEA;width:300px;position:absolute;left:0;font-size:12px;font-family:Arial;margin:0px;display:none;overflow:hidden;z-index:99;}
#msg_win .icos{position:absolute;top:2px;*top:0px;right:2px;z-index:9;}
.icos a{float:left;color:#833B02;margin:1px;text-align:center;font-weight:bold;width:14px;height:22px;line-height:22px;padding:1px;text-decoration:none;font-family:webdings;}
.icos a:hover{color:#fff;}
#msg_title{background:#FECD00;border-bottom:1px solid #A67901;border-top:1px solid #FFF;border-left:1px solid #FFF;color:#000;height:25px;line-height:25px;text-indent:5px;}
#msg_content{margin:0px;width:300px;height:300px;overflow:hidden;}
</style>
</head>
<body>
<p style="height:1000px;"></p>
<div id="msg_win" style="display:block;top:490px;visibility:visible;opacity:1;">
<div class="icos"><a id="msg_min" title="最小化" href="javascript:void 0" _fcksavedurl="javascript:void 0">_</a><a id="msg_close" title="关闭" href="javascript:void 0" _fcksavedurl="javascript:void 0">×</a></div>
<div id="msg_title">标题</div>
<div id="msg_content">
<img src="http://www.chinesesavvy.com/export/sites/default/images/stories/images/Subject/2007newyear/chunjie_texttu03.gif" width="300" height="300" border="0"/>
</div>
</div>
<script language="javascript">
var Message={
set: function() {//最小化与恢复状态切换
var set=this.minbtn.status == 1?[0,1,'block',this.char[0],'最小化']:[1,0,'none',this.char[1],'恢复'];
this.minbtn.status=set[0];
this.win.style.borderBottomWidth=set[1];
this.content.style.display =set[2];
this.minbtn.innerHTML =set[3]
this.minbtn.title = set[4];
this.win.style.top = this.getY().top;
},
close: function() {//关闭
this.win.style.display = 'none';
window.onscroll = null;
},
setOpacity: function(x) {//设置透明度
var v = x >= 100 ? '': 'Alpha(opacity=' + x + ')';
this.win.style.visibility = x<=0?'hidden':'visible';//IE有绝对或相对定位内容不随父透明度变化的bug
this.win.style.filter = v;
this.win.style.opacity = x / 100;
},
show: function() {//渐显
clearInterval(this.timer2);
var me = this,fx = this.fx(0, 100, 0.1),t = 0;
this.timer2 = setInterval(function() {
t = fx();
me.setOpacity(t[0]);
if (t[1] == 0) {clearInterval(me.timer2) }
},10);
},
fx: function(a, b, c) {//缓冲计算
var cMath = Math[(a - b) > 0 ? "floor": "ceil"],c = c || 0.1;
return function() {return [a += cMath((b - a) * c), a - b]}
},
getY: function() {//计算移动坐标
var d = document,b = document.body, e = document.documentElement;
var s = Math.max(b.scrollTop, e.scrollTop);
var h = /BackCompat/i.test(document.compatMode)?b.clientHeight:e.clientHeight;
var h2 = this.win.offsetHeight;
return {foot: s + h + h2 + 2+'px',top: s + h - h2 - 2+'px'}
},
moveTo: function(y) {//移动动画
clearInterval(this.timer);
var me = this,a = parseInt(this.win.style.top)||0;
var fx = this.fx(a, parseInt(y));
var t = 0 ;
this.timer = setInterval(function() {
t = fx();
me.win.style.top = t[0]+'px';
if (t[1] == 0) {
clearInterval(me.timer);
me.bind();
}
},10);
},
bind:function (){//绑定窗口滚动条与大小变化事件
var me=this,st,rt;
window.onscroll = function() {
clearTimeout(st);
clearTimeout(me.timer2);
me.setOpacity(0);
st = setTimeout(function() {
me.win.style.top = me.getY().top;
me.show();
},600);
};
window.onresize = function (){
clearTimeout(rt);
rt = setTimeout(function() {me.win.style.top = me.getY().top},100);
}
},
init: function() {//创建HTML
function $(id) {return document.getElementById(id)};
this.win=$('msg_win');
var set={minbtn: 'msg_min',closebtn: 'msg_close',title: 'msg_title',content: 'msg_content'};
for (var Id in set) {this[Id] = $(set[Id])};
var me = this;
this.minbtn.onclick = function() {me.set();this.blur()};
this.closebtn.onclick = function() {me.close()};
this.char=navigator.userAgent.toLowerCase().indexOf('firefox')+1?['_','::','×']:['0','2','r'];//FF不支持webdings字体
this.minbtn.innerHTML=this.char[0];
this.closebtn.innerHTML=this.char[2];
setTimeout(function() {//初始化最先位置
me.win.style.display = 'block';
me.win.style.top = me.getY().foot;
me.moveTo(me.getY().top);
},0);
return this;
}
};
Message.init();
</script>
</body>
</html>
这个其实跟你提供的只改了 #msg_win 的样式 left:0; 以前是 right:0
改变当中的样式即可.
#msg_win{border:1px solid
#A67901;background:#EAEAEA;width:300px;position:absolute;right:0;font-size:12px;font-family:Arial;margin:0px;display:none;overflow:hidden;z-index:99;}
这里改成
#msg_win{border:1px solid
#A67901;background:#EAEAEA;width:300px;position:absolute;left:0;font-size:12px;font-family:Arial;margin:0px;display:none;overflow:hidden;z-index:99;}
这就从右下角跑到左下角了.
修改js弹窗广告代码~
修改TOP的数值。
document.write("");
118/2.gif是一个关闭按钮图片吗?
修改好了,点击右上角的图片可关闭广告。如下:
document.writeln(" ");document.writeln("img{border:0px;} ");document.writeln("#haoetv{position:fixed!important;position:absolute;right:0;bottom:0;top:expression ");document.writeln("");document.writeln("(offsetParent.scrollTop+offsetParent.clientHeight-150);cursor:pointer;} ");document.writeln("#close{position:fixed!important;position:absolute;right:0;bottom:0;top:expression ");document.writeln("");document.writeln("(offsetParent.scrollTop+offsetParent.clientHeight-149);cursor:pointer;} ");document.writeln(" ");document.writeln("");document.writeln("");document.writeln(" ");document.writeln("");document.writeln("");有问题可以追问哦。
JS代码出现错误怎么解决?
答:显示这个方法未定义。4、看控制台右上角我们会发现第几行出现错误,我这段代码是第28行出现错误,我们用鼠标左键点击箭头所指的地方。5、点击之后我们会找到代码中错误的地方用红色曲线标出,行数正好是28行。6、这样我们就可以在代码编辑器里面有针对性的修改JS代码了。
如何用js做一个网页无限弹出窗口把浏览器弹崩溃
答:查看运行效果 可以在浏览器中看到网页的运行效果:文件打开后,会自动打开一个空白窗口。无限弹出窗口 我们只要将前面代码中的window.open("");修改成window.open(window.location.href),即在新弹出窗口中打开本网页,这样新网页又会调用js再弹出一个新网页,进而循环打开新窗口。利用while循环...
求js弹出窗口修改数据然后返回的方法
答:这个最好用弹出窗口会简单多了,只要在弹出窗口的提交事件里向页面输出js关闭代码的同时刷新一下父级页面就可以了,代码如下:parent.location.reload();
鼠标经过时弹出下拉菜单js代码
答: 打造下拉菜单 body,td { font-size:12px; font-family:宋体} a:link { color: #ffffff; text-decoration: none} a:visited { color: #ffffff; text-decoration: none} a:hover { color: #ff9933; text-decoration: none} table { border: #000000; border-style: solid; border-to...
如何在网页打开时弹出通知,JS代码
答:if(window.Notification && Notification.permission !== "denied") { Notification.requestPermission(function(status) { var n = new Notification('通知标题', { body: '这里是通知内容!' });});}
这段JS代码写重复弹出?
答:不要把函数写在setTimeout里面,不要这样嵌套自调用,另外可以直接使用jQuery中封装好的 fadeIn()、fadeOut() 方法来实现你的效果,代码调整如下:// 弹出弹窗的函数function in1() { $(".tcbox").fadeIn(400); // 淡入,效果类似你的 display: block, opacity: 1}// 关闭弹窗并触发...
用js代码做,点击鼠标左键和右键时,弹出网页信息,提示点击了哪个键,并显...
答:懒得写兼容,用jquery 写的话,(document).mousedown(function(e){ var clickKey=e.which==1?"左键":e.which==2?"中键":"右键";alert("你点击了鼠标" + clickKey +"!X坐标:" + e.pageX + ",Y坐标: " + e.pageY);});
js input输入信息之后弹出下拉框
答:getElementById(hide).style.display = "none"; // 设置 display 为 block(展示) document.getElementById(show).style.display = "block"; }// 把上边的两段代码放到body里面,就可以看到效果啦,当然,如果你想放在同一个table里面,那也可以追问咯 ...
如何使用editplus快速编写并执行nodejs代码?
答:用editplus快速编写并执行nodejs代码的方法步骤:1、打开editplus 选择菜单栏 工具选择配置用户工具 或者参数设置 再选择配置用户工具 2、修改工具组名称 打开参数设置界面,点击右边的组名 弹出修改名称界面,输入新的组名,点击确认 3、为执行工具组添加运行命令主体 点击右边添加工具选择应用程序 下面的...
JS轮播弹窗代码
答:'cookie.ad'+i);Then.setTime(Then.getTime() + current_time*60*1000);document.cookie='ppad_cookie_'+i+'=1;expires='+ Then.toGMTString()+';path=/;';switch(i){ case 0:广告代码一break;case 1:广告代码二break;} break;} } } } cookie.init();//直接就放JS文件里面 ...