电脑疯子技术论坛|电脑极客社区

微信扫一扫 分享朋友圈

已有 638 人浏览分享

QQ和旺旺悬浮客服代码|【分享】

 关闭 [复制链接]
638 0
不多说了。上班有点忙。


  1. function scrollx(p) {
  2.     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;
  3.     if (o) {
  4.         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');
  5.         if (p.f && ie6) {
  6.             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" );';
  7.             dd.style.cssText += ';background-image: url(about:blank);background-attachment:fixed;';
  8.         } else {
  9.             if (!p.f) {
  10.                 w.onresize = w.onscroll = function () {
  11.                     clearInterval(timer);
  12.                     timer = setInterval(function () {
  13.                         //双选择为了修复chrome 下xhtml解析时dd.scrollTop为 0
  14.                         var st = (dd.scrollTop || db.scrollTop), c;
  15.                         c = st - o.offsetTop + (p.t != undefined ? p.t : (w.innerHeight || dd.clientHeight) - o.offsetHeight);
  16.                         if (c != 0) {
  17.                             o.style.top = o.offsetTop + Math.ceil(Math.abs(c) / 10) * (c < 0 ? -1 : 1) + 'px';
  18.                         } else {
  19.                             clearInterval(timer);
  20.                         }
  21.                     }, 10)
  22.                 }
  23.             }
  24.         }
  25.     }
  26. }
  27. scrollx({
  28.     id: 'divStayTopRight',
  29.     // l: 1000,
  30.     t: 200,
  31.     f: 0
  32. })
  33. /*
  34. id 你要滚动的内容的id
  35. l 横坐标的位置  不写为紧贴右边
  36. t 你要放在页面的那个位置默认是贴着底边 0是贴着顶边
  37. f 1表示固定 不写或者0表示滚动
  38. */
复制代码


/*
请保存为JS
*/

您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

关注

23

粉丝

2901

主题
精彩推荐
热门资讯
网友晒图
图文推荐

Powered by Pcgho! X3.4

© 2008-2022 Pcgho Inc.