myfloat = new Array( //飘广告数据,直接插入HTML代码多省事
"
"
);
function mObject(oName, fname){
var step = 2;
var delay = 80;
var width = document.body.clientWidth;
var height = document.body.clientHeight;
var Hoffset = oName.offsetHeight;
var Woffset = oName.offsetWidth;
var xPos = Math.round(Math.random()*width);
var yPos = Math.round(Math.random()*height);
var yon = Math.round(Math.random());
var xon = Math.round(Math.random());
var pause = true;
var interval;
oName.style.top = yPos;
this.changePos = function(){
oName.style.left = xPos + document.body.scrollLeft;
oName.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);
}
}
this.start = function(){
oName.visibility = "visible";
setInterval(fname+".changePos()", delay);
}
this.start();
}
for(var i=0;i'+myfloat[i]+'');
var cmd = 'oFloatDiv' + i + ' = new mObject(FloatDiv'+i+',"oFloatDiv'+i+'");';
eval(cmd);
}