js实现网页右下角浮动广告代码

发布时间:2011年10月18日      浏览次数:331 次
var ad_html = "<style>.RF_main { clear:both; float:right; width:235px; height:91px; right:10px; bottom:10px; font-family:Arial, Helvetica, sans-serif; overflow:hidden; background:url(/images/leo_right_feedback_bg.gif) top left no-repeat; position:absolute; z-index:1000; }            .RF_title { clear:both; margin-top:10px; line-height:20px; overflow:hidden; color:white; font-size:18px; font-weight:bold; text-align:center; }            .RF_content { clear:both; margin-top:5px; font-size:12px; text-align:center; }      </style>      <div id="RF_ID" class="RF_main">            <div class="RF_title">Share your thougths<br/> help us improve</div>            <div class="RF_content">by giving us <a href="/forms/leo_right_feedback_form.php" class="fd"><font color="#0803F7"><u>Feedback</u></font></a><script>setFormBox('fd',60,100)</script></div>      </div>";
document.write(ad_html);

function scrollx(p){      
      var d = document,dd = d.documentElement,db = d.body,w = window,o = d.getElementById(p.id),ie6 = /msie 6/i.test(navigator.userAgent),style,timer;
      if(o){
            o.style.cssText +=";position:"+(p.f&&!ie6?'fixed':'absolute')+";"+(p.l==undefined?'right:0;':'left:'+p.l+'px;')+(p.t!=undefined?'top:'+p.t+'px':'bottom:0');
            if(p.f&&ie6){
                  o.style.cssText +=';left:expression(documentElement.scrollLeft + '+(p.l==undefined?dd.clientWidth-o.offsetWidth:p.l)+' + "px");top:expression(documentElement.scrollTop +'+(p.t==undefined?dd.clientHeight-o.offsetHeight:p.t)+'+ "px" );';
                  dd.style.cssText +=';background-image: url(about:blank);background-attachment:fixed;';
            }else{
                  if(!p.f){
                        w.onresize = w.onscroll = function(){
                              clearInterval(timer);
                              timer = setInterval(
                                    function(){
                                    //双选择为了修复chrome 下xhtml解析时dd.scrollTop为 0
                                    var st = (dd.scrollTop||db.scrollTop),c;
                                    c = st - o.offsetTop + (p.t!=undefined?p.t:(w.innerHeight||dd.clientHeight)-o.offsetHeight);
                                    if(c!=0){
                                          o.style.top = o.offsetTop + Math.ceil(Math.abs(c)/10)*(c<0?-1:1) + 'px';
                                    }else{
                                          clearInterval(timer);
                                    }
                                    }
                              ,10)
                        }
                  }
            }
      }
}

scrollx({id:'RF_ID',l:'',t:document.documentElement.clientHeight - document.getElementById("RF_ID").offsetHeight - 200,f:0})
/*
id 你要滚动的内容的id
l 横坐标的位置 不写为紧贴右边
t 你要放在页面的那个位置默认是贴着底边 0是贴着顶边
f 1表示固定 不写或者0表示滚动
*/
免责声明:本站相关技术文章信息部分来自网络,目的主要是传播更多信息,如果您认为本站的某些信息侵犯了您的版权,请与我们联系,我们会即时妥善的处理,谢谢合作!