两款右下角浮动广告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.111cn.net/1999/xhtml">
<head>
<title> float message </title>
<base href="http://www.111cn.net/images/" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<style>
#msg_win{
border:1px solid #a67901;
background:#eaeaea;
width:240px;
position:absolute;right: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 url(bar_bg.gif) repeat-x 0 100%;
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:5px;
margin-right:0;
width:230px;
height:126px;
overflow:hidden;
}

</style>
</head>

<body>
<p style="background:#eee;width:10px;height:1000px"></p>

<script>
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=document.createelement('div');
  this.win.id="msg_win";
  this.win.innerhtml='<div class="icos"><a href="网页特效:void 0" title="最小化" id="msg_min">0</a><a href="javascript:void 0" title="关闭" id="msg_close">r</a></div><div id="msg_title">温馨提示</div><div id="msg_content"></div>';
  document.body.appendchild(this.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);
  },500);
  return this;
 }
};
message.init();
message.title.innerhtml = '时尚-型男索女潮流馆';
message.content.innerhtml = '<a href="about:blank"><img src=https://yunqi-tech.oss-cn-hangzhou.aliyuncs.com/egfashion.gif border=0 alt="" title="原单正品 时尚复古 唯我独尊 "></a>';
</script>
</body>
</html>

右下角浮动广告代码二

<html><head>
<title>网页特效观止|111cn.net|---页面右下角弹出类似qq或msn的消息提示</title>
<script language=javascript> 
<!-- 
 
/**//* 
**    ================================================================================================== 
**    类名:class_msn_message 
**    功能:提供类似msn消息框 
**    示例: 
    --------------------------------------------------------------------------------------------------- 
 
              //width:层宽度、height:层高度、caption:层的标题、title:题目类型、content:内容、userid:对应的数据库教程的id号
                var msg = new class_msn_message(width,height,caption,title,message,content,userid){ 
                msg.show(); 
 
    --------------------------------------------------------------------------------------------------- 
**    作者:ttyp 
**    邮件:[email]ttyp@21cn.com[/email] 
**    日期:2005-3-18 
**    ================================================================================================== 
**/ 
 
 
/**//* 
*    消息构造 
*/ 
var opopup = window.createpopup(); //ie5.5+ 
 var windowsurl="模拟qq右下角提示窗体.htm";//var windowsurl=null;//这个是windows的连接主地址:修改地址
 //width:层宽度、height:层高度、caption:层的标题、title:题目类型、content:内容、userid:对应的数据库的id号
function class_msn_message(width,height,caption,title,message,content,userid){ 
   // this.id     = id; 
    this.title  = title; 
    this.caption= caption; 
    this.message= message; 
    //this.target = target; 
    //this.action = action; 
    this.width    = width?width:200; 
    this.height = height?height:120; 
    this.timeout= 150; 
    this.speed    = 20;
    this.step    = 1;
    this.right    = screen.width -1; 
    this.bottom = screen.height;
    this.left    = this.right - this.width;
    this.top    = this.bottom - this.height;
    this.timer    = 0;
    this.pause    = false;
    this.close    = false;
    this.autohide    = true;
 contt=content;//内容
 idd=userid;

 
/**//* 
*    隐藏消息方法 
*/ 
class_msn_message.prototype.hide = function(){ 
    if(this.onunload()){ 

        var offset  = this.height>this.bottom-this.top?this.height:this.bottom-this.top;
        var me  = this; 

        if(this.timer>0){  
            window.clearinterval(me.timer); 
        } 

        var fun = function(){ 
            if(me.pause==false||me.close){
                var x  = me.left;
                var y  = 0;
                var width = me.width;
                var height = 0;
                if(me.offset>0){
                    height = me.offset;
                }
    
                y  = me.bottom - height;
    
                if(y>=me.bottom){
                    window.clearinterval(me.timer); 
                    me.pop.hide(); 
                } else {
                    me.offset = me.offset - me.step; 
                }
                me.pop.show(x,y,width,height);   
            }            
        } 

        this.timer = window.setinterval(fun,this.speed)     
    } 

 
/**//* 
*    消息卸载事件,可以重写 
*/ 
class_msn_message.prototype.onunload = function() { 
    return true; 

/**//* 
*    消息命令事件,要实现自己的连接,请重写它 

*/ 
class_msn_message.prototype.oncommand = function(){ 
   //this.close = true;
    this.hide();
 //获取到id号
 var xid=opopup.document.getelementbyid("hiddenid").value;
    window.open(windowsurl+"?id="+xid);//连接到的地址------------------可根据情况自己填写参数-------------------------需要修改
  
}
/**//* 
*    消息显示方法 
*/ 
class_msn_message.prototype.show = function(){ 

   
   
    this.pop = opopup; 
 
    var w = this.width; 
    var h = this.height; 
    var str = "<div style='border-right: #455690 1px solid; border-top: #a6b4cf 1px solid; z-index: 99999; left: 0px; border-left: #a6b4cf 1px solid; width: " + w + "px; border-bottom: #455690 1px solid; position: absolute; top: 0px; height: " + h + "px; background-color: #c9d3f3'>" 
        str += "<table style='border-top: #ffffff 1px solid; border-left: #ffffff 1px solid' cellspacing=0 cellpadding=0 width='100%' bgcolor=#cfdef4 border=0>" 
        str += "<tr>" 
        str += "<td style='font-size: 12px;color: #0f2c8c' width=30 height=24></td>" 
        str += "<td style='padding-left: 4px; font-weight: normal; font-size: 12px; color: #1f336b; padding-top: 4px' valign=middle width='100%'>" + this.caption + "</td>" 
        str += "<td style='padding-right: 2px; padding-top: 2px' valign=middle align=right width=19>" 
        str += "<span title=关闭 style='font-weight: bold; font-size: 12px; cursor: hand; color: red; margin-right: 4px' id='btsysclose' >×</span></td>" 
        str += "</tr>" 
        str += "<tr>" 
        str += "<td style='padding-right: 1px;padding-bottom: 1px' colspan=3 height=" + (h-28) + ">" 
        str += "<div style='border-right: #b9c9ef 1px solid; padding-right: 8px; border-top: #728eb8 1px solid; padding-left: 8px; font-size: 12px; padding-bottom: 8px; border-left: #728eb8 1px solid; width: 100%; color: #1f336b; padding-top: 8px; border-bottom: #b9c9ef 1px solid; height: 100%'>" + this.title + "<br>"                                      //这里的隐藏域用来存字段的id号hiddenid
                                                 //这里的btcommand是调用方法oncommand只执行方法体类的windowns.open地址    
        str += "<div style='word-break: break-all' align=left><input type='hidden' name='hiddenid' id='hiddenid' value='"+idd+"'/><a href='javascript:void(0)' hidefocus=false id='btcommand'><font color=#ff0000>【" + this.message + "】</font></a><br><font color=blue>"+contt+"</font></div>"//<a href='http://www.sohu.com' hidefocus=false id='ommand'>
                                                            //<font color=#ff0000>"+contt+"</font></a></div>"//这里是连接的地址   
        str += "</div>" 
        str += "</td>" 
        str += "</tr>" 
        str += "</table>" 
        str += "</div>" 
 
    opopup.document.body.innerhtml = str;
   
 
    this.offset  = 0;
    var me  = this; 

    opopup.document.body.onmouseo教程ver = function(){me.pause=true;}
    opopup.document.body.onmouseout = function(){me.pause=false;}

    var fun = function(){ 
        var x  = me.left;
        var y  = 0;
        var width    = me.width;
        var height    = me.height;

            if(me.offset>me.height){
                height = me.height;
            } else {
                height = me.offset;
            }

        y  = me.bottom - me.offset;
        if(y<=me.top){
            me.timeout--;
            if(me.timeout==0){
                window.clearinterval(me.timer); 
                if(me.autohide){
                    me.hide();
                }
            }
        } else {
            me.offset = me.offset + me.step;
        }
        me.pop.show(x,y,width,height);   

    } 
 
    this.timer = window.setinterval(fun,this.speed)     
 
    
 
    var btclose = opopup.document.getelementbyid("btsysclose"); 
 
    btclose.onclick = function(){ 
        me.close = true;
        me.hide(); 
    } 
 
    var btcommand = opopup.document.getelementbyid("btcommand"); 
    btcommand.onclick = function(){ 
        me.oncommand(); 
    }

/**//*
** 设置速度方法 www.111cn.net
**/
class_msn_message.prototype.speed = function(s){
    var t = 10;
    try {
        t = praseint(s);
    } catch(e){}
    this.speed = t;
}
/**//*
** 设置步长方法
**/
class_msn_message.prototype.step = function(s){
    var t = 1;
    try {
        t = praseint(s);
    } catch(e){}
    this.step = t;
}
 
class_msn_message.prototype.rect = function(left,right,top,bottom){
    try {
        this.left        = left    !=null?left:this.right-this.width;
        this.right        = right    !=null?right:this.left +this.width;
        this.bottom        = bottom!=null?(bottom>screen.height?screen.height:bottom):screen.height;
        this.top        = top    !=null?top:this.bottom - this.height;
    } catch(e){}
}
var msg1 = new class_msn_message(200,120,"短消息提示:","您有1封消息","标题:肚子饿了","内容:今天没有吃饭","11111111"); 
    msg1.rect(null,null,null,screen.height-50);
    msg1.speed    = 50;
    msg1.step    = 5;
    msg1.show(); 

//同时两个有闪烁,只能用层代替了,不过层不跨框架
//var msg2 = new class_msn_message("aa",200,120,"短消息提示:","您有2封消息","好的啊"); 
//   msg2.rect(100,null,null,screen.height);
//    msg2.show(); 
//--> 
</script>

<meta content="mshtml 6.00.2800.1106" name=generator></head>
<body></body></html>

时间: 2024-09-30 09:59:59

两款右下角浮动广告js代码的相关文章

兼容多浏览器右下角浮动广告js代码

兼容多浏览器右下角浮动广告js代码 var opp; var wh; var hi; var dialogright = function(title,content,height,width) {  var my = this;  this._title = title;  this._content = content;  this._height = height;  hi = height;  this._width = width;  wh = width;  this._time =

网站左右两边浮动广告JS代码

中介交易 SEO诊断 淘宝客 云主机 技术大厅 <SCRIPT language="JavaScript" src="js/flr.js"></SCRIPT> <SCRIPT language="JavaScript" src="js/fll.js"></SCRIPT> ---------------------------flr.js----------------------

jQuery 浮动广告实现代码_jquery

实现方法: 复制代码 代码如下: <!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>浮动广

基于javascript实现右下角浮动广告效果_javascript技巧

本文实例为大家分享了基于javascript实现右下角浮动广告效果,供大家参考,具体内容如下 效果图: 具体代码: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>右下角广告代码</title> <script type="text/javascript&q

网站顶部广告js代码

提示:您可以先修改部分代码再运行 网站顶部广告js代码 提示:您可以先修改部分代码再运行

一款 div隐藏/显示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.111cn.net /1999/xhtml"> <head> <meta http-equiv="co

js 右下角浮动广告代码(四种代码)

// 随即广告 document.write("<span id="tmpmsgdiv"></span>"); var randoms=math.floor(math.random()*5+1); if(randoms%2==0){    str="<a href="http://www.111cn.net/?tn=codefans" target="_blank"><img

js实现网站最上边可关闭的浮动广告条代码_javascript技巧

本文实例讲述了js实现网站最上边可关闭的浮动广告条.分享给大家供大家参考.具体如下: 这是一款广告条代码,平时浮动在网站最上边,可关闭,设计唯美简洁,带关闭按钮,自适应网页宽度,色调明了,相信有不少朋友会喜欢的. 运行效果截图如下: 在线演示地址如下: http://demo.jb51.net/js/2015/js-top-float-clase-able-adv-codes/ 具体代码如下: <html> <head> <title>网站页首可关闭广告条</ti

js带最小化与关闭按钮右下角浮动广告

_× 右下角漂浮广告效果: php教程浮动窗口内容:欢迎提出宝贵意见,谢谢! php教程 - 最专业的php教程网站 - 致力为中国php程序员们提供有质量的经验教程!