日期:2014-05-16  浏览次数:20266 次

【急求】JS移动悬浮QQ客服代码,兼容个浏览器!!
  需要兼容各个浏览器的,很多不兼容!就是在浏览器窗口中一直随意浮动的那种!!希望大家帮帮忙哦!!

------解决方案--------------------

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>www.lanrentuku.com</title>
</head>

<body style="height:2000px;">
<DIV id=img1 style="Z-INDEX: 100; LEFT: 2px; WIDTH: 59px; POSITION: absolute; TOP: 43px; HEIGHT: 61px;
 visibility: visible;"><a href="http://bbs.csdn.net/" target="_blank"><img src="http://avatar.profile.csdn.net/0/8/9/2_zell419.jpg" width="80" height="80" border="0"></a></DIV>
<div align="center">
  <p>
    <SCRIPT language="javascript">
var xPos = 300;
var yPos = 200; 
var step = 1;
var delay = 20; 
var height = 0;
var Hoffset = 0;
var Woffset = 0;
var yon = 0;
var xon = 0;
var pause = true;
var interval;
img1.style.top = yPos;
function changePos() 
{
width = document.body.clientWidth;
height = document.body.clientHeight;
Hoffset = img1.offsetHeight;
Woffset = img1.offsetWidth;
img1.style.left = xPos + document.body.scrollLeft;
img1.style.top = yPos + document.body.scrollTop;
if (yon) 
{yPos = yPos + step;}
else 
{yPos = yPos - step;}
if (yPos < 0) 
{yon = 1;yPos = 0;}
if (yPos >= (height - Hoffset)) 
{yon = 0;yPos = (height - Hoffset);}
if (xon) 
{xPos = xPos + step;}
else 
{xPos = xPos - step;}
if (xPos < 0) 
{xon = 1;xPos = 0;}
if (xPos >= (width - Woffset)) 
{xon = 0;xPos = (width - Woffset);   }