大幅度降落广告js代码(大幅度降落广告js代码怎么用)
admin 发布:2022-12-19 09:00 116
今天给各位分享大幅度降落广告js代码的知识,其中也会对大幅度降落广告js代码怎么用进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:
- 1、JS漂浮广告代码
- 2、谁可以给个JS漂浮广告的关闭代码?
- 3、js或者CSS带关闭的漂浮广告代码
- 4、弹出广告js代码 广告置于右下角的解决方法
- 5、js 代码,随页面滚动而滚动的浮动广告效果(带关闭按钮)
JS漂浮广告代码
给个简单的 也需引入jquery
Html:
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
html
head
title/title
script type="text/javascript" src="jquery-1.4.2.min.js"/script
script type="text/javascript"
$(function(){
$('#showWin').click(showWin);
function showWin(){
$('#floatWin').show('slow');
}
})
/script
/head
body
button id="showWin"显示窗口/button
div id="floatWin"
style="right:0px;bottom:0px;display:none; width: 200px;height: 200px; background-color: #cccccc;position: absolute;"
/div
/body
/html
最近项目里正好有类似需求 代码给出来供你研究下 需要jQuery支持
有什么疑问可以hi我
(function(){
$(function(){
$.ajax({
url: messagePath+'messageBox.do',
// dataType:'json',
success:function(json){
alert(json);
showMessages(json);
}
});
})
function showMessages(json){
if(json.messagecount0){
var messageBox ="div id=\"OTOS_MESSAGEBOX_CONTAINER\""+
" table id=\"OTOS_MESSAGEBOX_HEADER\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\""+
" tr"+
" td id=\"OTOS_MESSAGEBOX_HEADER_TEXT\"/td"+
" td align=\"right\" width=\"20\"img id=\"OTOS_MESSAGEBOX_CLOSE\" style=\"cursor: pointer;\" src=\"resources/images/close.gif\"/td"+
" /tr"+
" /table"+
" table id=\"OTOS_MESSAGEBOX_CONTEXT_TITLE_TABLE\" width=\"100%\""+
" tr id=\"OTOS_MESSAGEBOX_CONTEXT_TABLE_HEADER\""+
" td标题/td"+
" td width=\"50\"类型/td"+
" td width=\"40\"发送人/td"+
" /tr"+
" /table"+
" div id=\"OTOS_MESSAGEBOX_CONTEXT\""+
" table id=\"OTOS_MESSAGEBOX_CONTEXT_TABLE\" width=\"100%\"/table"+
" /div"+
"/div";
$('body').append(messageBox);
// $('#OTOS_MESSAGEBOX_CONTAINER').jqDrag("#OTOS_MESSAGEBOX_HEADER");
$('#OTOS_MESSAGEBOX_HEADER_TEXT').text("您有"+json.messagecount+"条未读消息!");
$('#OTOS_MESSAGEBOX_CLOSE').bind('click',closeMessageBox);
$('#OTOS_MESSAGEBOX_CONTAINER').show('slow');
for(var i=0;ijson.list.length;i++){
var map = json.list[i];
$('#OTOS_MESSAGEBOX_CONTEXT_TABLE').append("tr onClick=\"toViewMessage("+map.id+",+"+map.mid+")\" class=\"OTOS_MESSAGEBOX_CONTEXT_TABLE_TR\"td"+cutTitle(map.title)+"/tdtd width=\"50\" nowarp"+map.type+"/tdtd width=\"40\""+map.sender+"/td/tr");
}
$('#OTOS_MESSAGEBOX_CONTEXT_TABLE').verticalRoll({parentid:'OTOS_MESSAGEBOX_CONTEXT'});
}
}
// 纵向滚动
$.fn.verticalRoll = function(options) {
var opts = $.extend({}, $.fn.verticalRoll.defaults, options);
if(!opts.parentid||$('#'+opts.parentid).size()1){
alert('父级不存在');
return false;
}
var $p = $('#'+opts.parentid);
var $t = $(this);
if($t.attr('tagName')!='TABLE'){
alert('不是table');
return false;
}
var s = $t.find('tr').size()
$p.css('overflow','hidden');
$t.css('position','absolute');
if(s5){
window.setInterval(function(){
var temp = $t.find('tr:first');
temp.fadeOut('slow',function(){
$t.append(temp);
temp.show();
})
},2000)
}else{
return false;
}
$.fn.verticalRoll.defaults = {}
}
})(jQuery);
function closeMessageBox(){
$('#OTOS_MESSAGEBOX_CONTAINER').hide('slow');
$('#OTOS_MESSAGEBOX_CONTAINER').fadeOut();
}
function cutTitle(title){
var temp;
if(title.length8){
temp = title.substring(0,8)+"...";
return temp
}else{
return title;
}
}
function toViewMessage(id,rid){
window.location.href = "messagesUserList.do?id="+id+"rid="+rid;
}
Css文件
@CHARSET "UTF-8";
#OTOS_MESSAGEBOX_CONTAINER {
position: absolute;
width: 240px;
height: 145px;
border: 1px solid #81b8ff;
background-color: #deecfd;
right: 0px;
bottom: 0px;
overflow:hidden;
display: none;
}
#OTOS_MESSAGEBOX_CONTAINER TD{
white-space: nowrap;
overflow: hidden;
height: 18px;
}
#OTOS_MESSAGEBOX_HEADER {
cursor: move;
border-bottom: 1px solid #81b8ff;
background-color: #9ACDFE;
overflow:hidden;
}
#OTOS_MESSAGEBOX_HEADER td {
padding: 2px;
color: #ffffff;
overflow:hidden;
}
#OTOS_MESSAGEBOX_CONTEXT {
position: relative;
height: 102px;
overflow:hidden;
}
#OTOS_MESSAGEBOX_CONTEXT td{
white-space: nowrap;
overflow: hidden;
}
#OTOS_MESSAGEBOX_HEADER_TEXT {
font-weight: bold;
overflow:hidden;
}
#OTOS_MESSAGEBOX_FOOTER {
position: relative;;
bottom: 0px;;
padding-right: 2px;;
text-align: right;
overflow:hidden;
}
.OTOS_MESSAGEBOX_CONTEXT_TABLE_TR{
cursor:pointer;
color: #336699;
overflow:hidden;
}
#OTOS_MESSAGEBOX_CONTEXT_TABLE_HEADER td{
overflow:hidden;
font-weight: bold;
overflow:hidden;
}
谁可以给个JS漂浮广告的关闭代码?
function closead(){
document.getElementById("left").style.display="none";
document.getElementById("right").style.display="none";
}
div id="left"
p/p
a href="javascript:closead();" title="关闭广告"×关闭/a
/div
js或者CSS带关闭的漂浮广告代码
htmlheadtitle固定在底部的漂浮广告/title/headbodyscript LANGUAGE='JavaScript'var ad_float_left_src="http:/images/logo.gif";var ad_float_left_url = "http:";var ad_float_left_type = "";document.ns = navigator.appName == "Microsoft Internet Explorer"var imgheight_closevar imgleftwindow.screen.width800 ? imgheight_close=120:imgheight_close=120window.screen.width800 ? imgleft=15:imgleft=122function myload(){myleft.style.top=document.body.scrollTop+document.body.offsetHeight-imgheight_close;myleft.style.left=imgleft;leftmove();}function leftmove(){myleft.style.top=document.body.scrollTop+document.body.offsetHeight-imgheight_close;myleft.style.left=imgleft;setTimeout("leftmove();",50)}function MM_reloadPage(init) {if (init==true) with (navigator) {if ((appName=="Netscape")(parseInt(appVersion)==4)) {document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();}MM_reloadPage(true)function close_float_left(){myleft.style.visibility='hidden';}if(document.ns){document.write("div id=myleft style='position: absolute;width:80;top:300;left:5;visibility: visible;z-index: 1'styleA.closefloat:link,A.refloat:visited {text-decoration:none;color:#000000;font-size:12px}A.closefloat:active,A.refloat:hover {text-decoration:underline;color:#0000FF;font-size:12px}/styletable border=0 cellpadding=0 cellspacing=0trtd");if(ad_float_left_type!="swf")document.write("a href='" + ad_float_left_url + "' target = '_blank'img src='" + ad_float_left_src + "' WIDTH=100 HEIGHT=100 border = 0/a");elsedocument.write("EMBED src='" + ad_float_left_src + "' FlashVars='" + ad_float_left_url + "' quality=high WIDTH=80 HEIGHT=80 TYPE='application/x-shockwave-flash' id=changhongout /EMBED");document.write("/td/trtrtd width=80 height=20 align=righta href='javascript:close_float_left();void(0);' class=closefloatfont color=#0000ff size=2关闭font/a/td/tr/table/div");myload()}/script/body/html
弹出广告js代码 广告置于右下角的解决方法
可关闭,可最小化,带点淡入淡出效果的右下角弹出广告;
参考如下:
html
head
title右下角广告代码/title
style type="text/css"
#msg_win{border:1px solid #A67901;background:#EAEAEA;width:300px;position:absolute;right:2;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;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:2px;width:300px;height:200px;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"_/aa id="msg_close" title="关闭" href="javascript:void 0"×/a/div
div id="msg_title"广而告之:/div
div id="msg_content"a href="" target="_blank"img src="" width="300" height="270" border="0"/a/div
/div
/body
/html
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
js 代码,随页面滚动而滚动的浮动广告效果(带关闭按钮)
随滚动而滚动,css就可以实现,也就是固定在屏幕固定位置,用 position:fixed;即可,关闭按钮可以用document.getElementById('').style.display='none';即可,如
div style="width:500px; height:200px; background-color:#F00;position:fixed;left:100px;top:200px;" id="test"
button onclick="document.getElementById('test').style.display='none';"关闭/button
/div
其中left和top都是相对于屏幕的位置
关于大幅度降落广告js代码和大幅度降落广告js代码怎么用的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。
版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;
相关推荐
- 05-02微信公众号运营,微信公众号运营者怎么解绑
- 05-02js代码3d图片叠加旋转切换(js图片绕中心旋转的代码)[20240502更新]
- 05-02代码如何实现导航栏(做导航栏代码)[20240502更新]
- 05-02做网页菜单栏设计代码(网页设计菜单栏导航实例)[20240502更新]
- 05-02js颜色代码(js颜色代码对照表)[20240502更新]
- 05-02怎么交易源代码(源码交易网站有哪些)[20240502更新]
- 05-02百度空间c代码(百度空间c代码是多少)[20240502更新]
- 05-02淘宝右侧导航条css代码(淘宝右侧导航条css代码)[20240502更新]
- 05-02cs游戏代码(cs进入游戏代码)[20240502更新]
- 05-02百度怎么打广告,百度怎么打广告免费
取消回复欢迎 你 发表评论:
- 标签列表
- 最近发表
- 友情链接