在給你們推薦了《QQ在線客服代碼能夠拖動浮動》而後又推薦了《QQ在線諮詢代碼上下浮動型》以後,有朋友問我有沒有簡單點的可浮動的在線QQ諮詢客服代碼,實際上是有的,我先賣個關子說說原理。算了仍是上傳個在線qq諮詢客服代碼的演示圖片吧。以下圖:html
樣子很難看,可是這就是很是簡潔的浮動qq客服代碼了,其實最簡單的QQ在線客服代碼仍是http://imis.qq.com/webpresence/code.shtml官方的,不過不能浮動。等下提供源程序的打包下載。web
先看浮動部分的代碼,這個floaters函數就是讓一個div元素浮動函數
function floaters() {this
this.items = [];code
this.addItem = function(id,x,y,content) {htm
document.write('圖片
'+content+'');get
var newItem = {};string
newItem.object = document.getElementById(id);it
newItem.x = x;
newItem.y = y;
this.items[this.items.length] = newItem;
}
this.play = function() {
collection = this.items
setInterval('play()',10);
}
}
而後是顯示部分的代碼,play這個函數是控制在線qq諮詢客服代碼的顯示的:
function play() {
if(screen.width<=800) {
for(var i=0;i
collection[i].object.style.display = 'none';
}
return;
}
for(var i=0;i
var followObj = collection[i].object;
var followObj_x = (typeof(collection[i].x)=='string'?eval(collection[i].x):collection[i].x);
var followObj_y = (typeof(collection[i].y)=='string'?eval(collection[i].y):collection[i].y);
if(followObj.offsetLeft!=(document.body.scrollLeft+followObj_x)) {
var dx=(document.body.scrollLeft+followObj_x-followObj.offsetLeft)*delta;
dx=(dx>0?1:-1)*Math.ceil(Math.abs(dx));
followObj.style.left=followObj.offsetLeft+dx;http://www.hrbfc120.com
}
if(followObj.offsetTop!=(document.body.scrollTop+followObj_y)) {
var dy=(document.body.scrollTop+followObj_y-followObj.offsetTop)*delta;
dy=(dy>0?1:-1)*Math.ceil(Math.abs(dy));
followObj.style.top=followObj.offsetTop+dy;
}
followObj.style.display = '';
}
}