求助分析一下网页代码 谢谢
答案:1 悬赏:30 手机版
解决时间 2021-02-19 13:48
- 提问者网友:川水往事
- 2021-02-18 23:18
求助分析一下网页代码 谢谢
最佳答案
- 五星知识达人网友:一秋
- 2021-02-18 23:37
function floaters() {
this.items = []; //创建items空数组
this.addItem = function(id,x,y,content) //创建addItem方法
{
document.write(''+content+'');
//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 {
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(''+content+'');
//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
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方法
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯