PageAdmin网站内容管理系统(CMS)交流论坛

注册

 

QQ登录

只需一步,快速开始

发新话题 回复该主题

在线客服怎么样才能随屏幕飘浮,JS用多了是不是会影响速度和安全 [复制链接]

1#
我在网上找了一段QQ在线飘浮的JS代码,想加到网站上,但是我试了很多的地方都不能正常浮动,我试过把代码写到所有的站内广告位上,结果全部是不显示,加到网站页眉和页尾,还有首页上的任何一个导航,模块上都是固定在了上方,跟本不能随屏幕移动,应该怎么弄才能正常浮动,单独拿个页面出来写上代码是能正常浮动的,请大侠们帮我看看怎么弄,还有JS多了是不是会影响网站访问速度和安全呢?下面我把代码贴上来
<html>
<head>
<meta http-equiv="Content-Type" c>
<title>QQ在线客服</title>
</head>
<body>
<DIV id=divStay style="POSITION: absolute">
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
    <TD vAlign=top width="7%"></TD></TR></TBODY></TABLE></DIV>
<SCRIPT language=javascript>
function picsize(obj,MaxWidth){
  img=new Image();
  img.src=obj.src;
  if (img.width>MaxWidth)
  {
    return MaxWidth;
  }
  else
  {
    return img.width;
  }
}
function CloseQQ()
{
divStayTopleft.style.display="none";
return true;
}
var online= new Array();
</SCRIPT>
<div id="divStayTopleft" style="POSITION: absolute">
<table cellspacing="0" cellpadding="0" width="109" border="0">
  <tr>
   <td colspan="3">
   <a  href="javascript:;" shape="circle" coords="91,16,12">
   <img height="34" src="http://www.codefans.net/jscss/demoimg/qq_top.gif" width="109" usemap="#Map" border="0"></a></td>
  </tr>
  <tr>
   <td width="6"><img height="100" src="http://www.codefans.net/jscss/demoimg/qq_life.gif" width="6"></td>
   <td valign="top" width="96" background="sto/qq_bg.gif">
   <table cellspacing="0" cellpadding="0" width="90" align="center" border="0">
    <tr>
     <td height="30">
     <table cellspacing="0" cellpadding="0" width="90" border="0">
      <tr>
       <td>
       <img height="13" src="http://www.codefans.net/jscss/demoimg/qq_ico1.gif" width="16"><span class="font_12">
       <span style="font-size: 12px">在线客服</span></span></td>
      </tr>
     </table>
     </td>
    </tr>
    <tr>
     <td>
     <table border="0" width="100%" cellpadding="2" id="table47">
      <tr>
       <td width="15" valign="top" height="23">
       <img border="0" src="http://www.codefans.net/jscss/demoimg/qq_v01.gif" width="16" height="16"></td>
       <td valign="bottom"><script>document.write("<a target=blank href=tencent://message/?uin=123456&Site=源码爱好者&Menu=yes><img border=0 SRC=http://wpa.qq.com/pa?p=1:615050000:10 alt=[源码爱好者]></a>");</script></td>
      </tr>
     </table>
     </td>
    </tr>
    <tr>
     <td></td>
    </tr>
    <tr>
     <td>
     <table border="0" width="100%" cellpadding="2" id="table47">
      <tr>
       <td width="15" valign="top" height="23">
       <img border="0" src="http://www.codefans.net/jscss/demoimg/qq_n01.gif" width="16" height="16"></td>
       <td valign="bottom"><script>document.write("<a target=blank href=tencent://message/?uin=123456&Site=源码爱好者&Menu=yes><img border=0 SRC=http://wpa.qq.com/pa?p=1:43486831:10 alt=[源码爱好者]></a>");</script></td>
      </tr>
     </table>
     </td>
    </tr>
    <tr>
     <td></td>
    </tr>
   </table>
   </td>
   <td width="7"><img height="100" src="http://www.codefans.net/jscss/demoimg/qq_right.gif" width="7"></td>
  </tr>
  <tr>
   <td colspan="3">
   <img height="30" src="http://www.codefans.net/jscss/demoimg/qq_bottom1.gif" width="109"></td>
  </tr>
  <tr>
   <td colspan="3"><a href="http://www.codefans.net" target="_blank"><img height="33" src="http://www.codefans.net/jscss/demoimg/qq_logo.gif" width="109" border="0"></a></td>
  </tr>
</table>
</div>
<script type="text/javascript">
function FloatTop()
{
var startX1 =document.body.offsetWidth-125 ,startY1 = 5;
var startX2 =0,startY2 = 95;
var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;
function ml(id,startX,startY)
{
  var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
  if(d.layers)el.style=el;
  el.sP=function(x,y){this.style.left=x;this.style.top=y;};
  el.x = startX;
  el.y = startY;
  return el;
}
window.stayTopLeft=function()
{
  var pY = ns ? pageYOffset : document.body.scrollTop;
  ftlObj.y += (pY + startY1 - ftlObj.y)/8;
  ftlObj1.y += (pY + startY2 - ftlObj1.y)/8;
  ftlObj.sP(document.body.scrollLeft+document.body.offsetWidth-125, ftlObj.y);
  ftlObj1.sP(ftlObj1.x, ftlObj1.y);
  setTimeout("stayTopLeft()", 30);
}
ftlObj = ml("divStay",(document.body.scrollLeft+document.body.offsetWidth)/2+379,0);
ftlObj1 = ml("divStayTopLeft",(document.body.scrollLeft+document.body.offsetWidth)/2+379,30);
stayTopLeft();
}
FloatTop();
</script>
<!--End -->
<table><tr><td height="800"></td></tr></table>
</body>
</html>
分享 转发
TOP
2#

         我想知道为什么管理不回答这个问题 ?
TOP
3#

在基本设置里放页尾就OK了
TOP
4#

页尾早就试过了,只要能放源代码的地方我基本上都试过了,放了以后是可以显示出来,但问题是不能随窗口自动往下移,只能固定在一个地方,但实际上这段代码是可以实现随窗口自动下移的
TOP
5#

你自己不用写什么JS,直接把HTML部分复制到站内广告信息的对联广告中就可以了
TOP
6#

试过的,这个方法虽然可以随屏幕移动,但是右侧广告永远只显示一个最边上的框线,看不到在线客服的全部界面,向右拖动滚动条倒是能看到,但是只要点一下任何一个地方,又跑到最右边了,而且右边是无限长的延伸,永远都不能正好显示出在线客服的全界面来,而左边那一个,放上代码根本就不显示,我推测可能是跑到最左边去了,以至于显示不到正常页面范围内,我把这段JS代码贴上来,xiyou帮我看一下什么原因吧,谢谢啦,以下是代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>QQ在线客服</title>
</head>
<body>
<DIV id=divStay style="POSITION: absolute">
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
    <TD vAlign=top width="7%"></TD></TR></TBODY></TABLE></DIV>
<SCRIPT language=javascript>
function picsize(obj,MaxWidth){
  img=new Image();
  img.src=obj.src;
  if (img.width>MaxWidth)
  {
    return MaxWidth;
  }
  else
  {
    return img.width;
  }
}
function CloseQQ()
{
divStayTopleft.style.display="none";
return true;
}
var online= new Array();
</SCRIPT>
<div id="divStayTopleft" style="POSITION: absolute">
<table cellspacing="0" cellpadding="0" width="109" border="0">
  <tr>
   <td colspan="3">
   <a onclick="CloseQQ()" href="javascript:;" shape="circle" coords="91,16,12">
   <img height="34" src="http://www.codefans.net/jscss/demoimg/qq_top.gif" width="109" usemap="#Map" border="0"></a></td>
  </tr>
  <tr>
   <td width="6"><img height="100" src="http://www.codefans.net/jscss/demoimg/qq_life.gif" width="6"></td>
   <td valign="top" width="96" background="sto/qq_bg.gif">
   <table cellspacing="0" cellpadding="0" width="90" align="center" border="0">
    <tr>
     <td height="30">
     <table cellspacing="0" cellpadding="0" width="90" border="0">
      <tr>
       <td>
       <img height="13" src="http://www.codefans.net/jscss/demoimg/qq_ico1.gif" width="16"><span class="font_12">
       <span style="font-size: 12px">在线客服</span></span></td>
      </tr>
     </table>
     </td>
    </tr>
    <tr>
     <td>
     <table border="0" width="100%" cellpadding="2" id="table47">
      <tr>
       <td width="15" valign="top" height="23">
       <img border="0" src="http://www.codefans.net/jscss/demoimg/qq_v01.gif" width="16" height="16"></td>
       <td valign="bottom"><script>document.write("<a target=blank href=tencent://message/?uin=123456&Site=源码爱好者&Menu=yes><img border=0 SRC=http://wpa.qq.com/pa?p=1:615050000:10 alt=[源码爱好者]></a>");</script></td>
      </tr>
     </table>
     </td>
    </tr>
    <tr>
     <td></td>
    </tr>
    <tr>
     <td>
     <table border="0" width="100%" cellpadding="2" id="table47">
      <tr>
       <td width="15" valign="top" height="23">
       <img border="0" src="http://www.codefans.net/jscss/demoimg/qq_n01.gif" width="16" height="16"></td>
       <td valign="bottom"><script>document.write("<a target=blank href=tencent://message/?uin=123456&Site=源码爱好者&Menu=yes><img border=0 SRC=http://wpa.qq.com/pa?p=1:43486831:10 alt=[源码爱好者]></a>");</script></td>
      </tr>
     </table>
     </td>
    </tr>
    <tr>
     <td></td>
    </tr>
   </table>
   </td>
   <td width="7"><img height="100" src="http://www.codefans.net/jscss/demoimg/qq_right.gif" width="7"></td>
  </tr>
  <tr>
   <td colspan="3">
   <img height="30" src="http://www.codefans.net/jscss/demoimg/qq_bottom1.gif" width="109"></td>
  </tr>
  <tr>
   <td colspan="3"><a href="http://www.codefans.net" target="_blank"><img height="33" src="http://www.codefans.net/jscss/demoimg/qq_logo.gif" width="109" border="0"></a></td>
  </tr>
</table>
</div>
<script type="text/javascript">
function FloatTop()
{
var startX1 =document.body.offsetWidth-125 ,startY1 = 5;
var startX2 =0,startY2 = 95;
var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;
function ml(id,startX,startY)
{
  var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
  if(d.layers)el.style=el;
  el.sP=function(x,y){this.style.left=x;this.style.top=y;};
  el.x = startX;
  el.y = startY;
  return el;
}
window.stayTopLeft=function()
{
  var pY = ns ? pageYOffset : document.body.scrollTop;
  ftlObj.y += (pY + startY1 - ftlObj.y)/8;
  ftlObj1.y += (pY + startY2 - ftlObj1.y)/8;
  ftlObj.sP(document.body.scrollLeft+document.body.offsetWidth-125, ftlObj.y);
  ftlObj1.sP(ftlObj1.x, ftlObj1.y);
  setTimeout("stayTopLeft()", 30);
}
ftlObj = ml("divStay",(document.body.scrollLeft+document.body.offsetWidth)/2+379,0);
ftlObj1 = ml("divStayTopLeft",(document.body.scrollLeft+document.body.offsetWidth)/2+379,30);
stayTopLeft();
}
FloatTop();
</script>
<!--End -->
<table><tr><td height="800"></td></tr></table>
</body>
</html>
TOP
7#

PageAdmin CMS用户交流群327432775,可以加群一起探讨建站技术。
TOP
发新话题 回复该主题