求助分析一下网页代码 谢谢
functionfloaters(){this.items=[];this.addItem=function(id,x,y,content){document.write...
function floaters() {
this.items = [];
this.addItem = function(id,x,y,content)
{
document.write('<DIV id='+id+' style="Z-INDEX: 10; POSITION: absolute; width:60px; height:60px;right:'+(typeof(x)=='string'?eval(x):x)+';top:'+(typeof(y)=='string'?eval(y):y)+'">'+content+'</DIV>');
var newItem = {};
newItem.object = document.getElementById(id);
newItem.x = x;
newItem.y = y;
this.items[this.items.length] = newItem;
}
this.play = function()
{
collection = this.items
setInterval('play()',10);
}
}
function play()
{
for(var i=0;i<collection.length;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;
}
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 = '';
}
}
var theFloaters = new floaters();
theFloaters.addItem('followDiv1','document.body.clientWidth-100',230,''+right_img+'');
theFloaters.addItem('followDiv2',20,230,''+left_img+'');
theFloaters.play(); 展开
this.items = [];
this.addItem = function(id,x,y,content)
{
document.write('<DIV id='+id+' style="Z-INDEX: 10; POSITION: absolute; width:60px; height:60px;right:'+(typeof(x)=='string'?eval(x):x)+';top:'+(typeof(y)=='string'?eval(y):y)+'">'+content+'</DIV>');
var newItem = {};
newItem.object = document.getElementById(id);
newItem.x = x;
newItem.y = y;
this.items[this.items.length] = newItem;
}
this.play = function()
{
collection = this.items
setInterval('play()',10);
}
}
function play()
{
for(var i=0;i<collection.length;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;
}
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 = '';
}
}
var theFloaters = new floaters();
theFloaters.addItem('followDiv1','document.body.clientWidth-100',230,''+right_img+'');
theFloaters.addItem('followDiv2',20,230,''+left_img+'');
theFloaters.play(); 展开
1个回答
展开全部
function floaters() {
this.items = []; //创建items空数组
this.addItem = function(id,x,y,content) //创建addItem方法
{
document.write('<DIV id='+id+' style="Z-INDEX: 10; POSITION: absolute; width:60px; height:60px;right:'+(typeof(x)=='string'?eval(x):x)+';top:'+(typeof(y)=='string'?eval(y):y)+'">'+content+'</DIV>');
//typeof(x)指x的数据类型,typeof(y)同理
var newItem = {};
//声明newItem空对象,相当于var newItem=new Object(){}
newItem.object = document.getElementById(id);
//对象的object属性是document.getElementById(id)所获得的对象的句柄
newItem.x = x;
newItem.y = y;
//对象的x,y属性的赋值
this.items[this.items.length] = newItem;
//items空数组赋值为newItem数组
}
this.play = function() //创建play方法
{
collection = this.items
setInterval('play()',10);
}
}
function play()
{
for(var i=0;i<collection.length;i++)
{
var followObj = collection[i].object;
//遍历collection数组的每个元素
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;
}
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 = '';
}
}
//这两个if条件语句用来移动followObj对象的位置,最后将followObj对象隐藏
var theFloaters = new floaters();
//将floaters()函数实例化
theFloaters.addItem('followDiv1','document.body.clientWidth-100',230,''+right_img+'');
theFloaters.addItem('followDiv2',20,230,''+left_img+'');
//运用实例对象theFloaters的addItem方法
theFloaters.play();
//运用实例对象theFloaters的play方法
this.items = []; //创建items空数组
this.addItem = function(id,x,y,content) //创建addItem方法
{
document.write('<DIV id='+id+' style="Z-INDEX: 10; POSITION: absolute; width:60px; height:60px;right:'+(typeof(x)=='string'?eval(x):x)+';top:'+(typeof(y)=='string'?eval(y):y)+'">'+content+'</DIV>');
//typeof(x)指x的数据类型,typeof(y)同理
var newItem = {};
//声明newItem空对象,相当于var newItem=new Object(){}
newItem.object = document.getElementById(id);
//对象的object属性是document.getElementById(id)所获得的对象的句柄
newItem.x = x;
newItem.y = y;
//对象的x,y属性的赋值
this.items[this.items.length] = newItem;
//items空数组赋值为newItem数组
}
this.play = function() //创建play方法
{
collection = this.items
setInterval('play()',10);
}
}
function play()
{
for(var i=0;i<collection.length;i++)
{
var followObj = collection[i].object;
//遍历collection数组的每个元素
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;
}
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 = '';
}
}
//这两个if条件语句用来移动followObj对象的位置,最后将followObj对象隐藏
var theFloaters = new floaters();
//将floaters()函数实例化
theFloaters.addItem('followDiv1','document.body.clientWidth-100',230,''+right_img+'');
theFloaters.addItem('followDiv2',20,230,''+left_img+'');
//运用实例对象theFloaters的addItem方法
theFloaters.play();
//运用实例对象theFloaters的play方法
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询