复制代码代码如下:
<! - 首页图片漂浮开始->
<script type =“ text/javascript” language =“ javaScript”>
函数addevent(obj,evttype,func,cap){
CAP = CAP ||错误的;
if(obj.addeventlistener){
OBJ.AddeventListener(EvtType,Func,Cap);
返回true;
} else if(obj.attachevent){
如果(cap){
obj.setCapture();
返回true;
} 别的 {
返回obj.attachevent(“ on” + evttype,func);
}
} 别的 {
返回false;
}
}
函数getPagesCroll(){
var xscroll,yscroll;
如果(self.pagexoffset){
xsCroll = self.pagexoffset;
} else if(document.documentElement && document.documentElement.scrollleft){
xsCroll = document.documentElement.scrollleft;
} else if(document.body){
xsCroll = document.body.scrollleft;
}
如果(self.pageyOffset){
yscroll = self.pageyOffset;
} else if(document.documentElement && document.documentElement.scrolltop){
yscroll = document.documentElement.scrolltop;
} else if(document.body){
yscroll = document.body.scrolltop;
}
ArrayPagesCroll = new Array(XSCroll,YSCroll);
返回arraypagesCroll;
}
函数getPagesize(){
var xscroll,yscroll;
if(window.innerheight && window.scrollmaxy){
xsCroll = document.body.scrollwidth;
yscroll = window.innerheight + window.scrollmaxy;
} else if(document.body.scrollheight> document.body.offsetheight){
xsCroll = document.body.scrollwidth;
yscroll = document.body.scrollheight;
} 别的 {
XSCroll = document.body.offsetWidth;
yscroll = document.body.offsetheight;
}
var窗口宽度,窗口高;
如果(self.innerheight){
windowwidth = self.innerwidth;
windowheight = self.innerheight;
} else if(document.documentElement && document.documentElement.ClientHeight){
WindowWidth = document.documentElement.ClientWidth;
WindowHeight = document.documentElement.ClientHeight;
} else if(document.body){
WindowWidth = Document.Body.ClientWidth;
windowHeight = document.body.clientheight;
}
如果(yscroll <windowheight){
pageheight = windowheight;
} 别的 {
pageheight = yscroll;
}
如果(xscroll <windowwidth){
pageWidth = WindowWidth;
} 别的 {
pageWidth = xscroll;
}
arraypagesize = new Array(pagewidth,pageheight,windowwidth,windowheight)
返回arraypagesize;
}
var AdmoveConfig = new Object();
Admoveconfig.isinitialized = false;
AdmoveConfig.Scrollx = 0;
AdmoveConfig.Scrolly = 0;
AdmoveConfig.MoveWidth = 0;
AdmoveConfig.MoveHeight = 0;
AdmoveConfig.Resize = function(){
var winsize = getPagesize();
AdmoveConfig.MoveWidth = WinSize [2];
AdmoveConfig.MoveHeight = WinSize [3];
AdmoveConfig.Scroll();
}
AdmoveConfig.Scroll = function(){
var winsCroll = getPagesCroll();
AdmoveConfig.Scrollx = winsCroll [0];
AdmoveConfig.Scrolly = WinScroll [1];
}
addEvent(窗口,“调整大小”,admoveConfig.resize);
addevent(窗口,“滚动”,AdmoveConfig.scroll);
功能ADMOVE(ID){
if(!admoveconfig.isinitialized){
AdmoveConfig.resize();
Admoveconfig.isinitialized = true;
}
var obj = document.getElementById(id);
obj.style.position =“ absolute”;
var w = admoveConfig.moveWidth -obj.offsetWidth;
var h = AdmoveConfig.MoveHeight -Obj.offsetheight;
var x = w * math.random(),y = h * math.random();
var rad =(Math.random() + 1) * Math.pi / 6;
var kx = math.sin(rad),ky = math.cos(rad);
var dirx =(Math.random()<0.5?1:-1),diry =(Math.random()<0.5?1:-1);
var step = 1;
var间隔;
this.setLocation = function(vx,vy){x = vx; y = vy; }
this.setDirection = function(vx,vy){dirx = vx; diry = vy; }
obj.custommethod = function(){
obj.style.left =(x + admoveconfig.scrollx) +“ px”;
obj.style.top =(y + admoveconfig.scrolly) +“ px”;
rad =(Math.random() + 1) * Math.pi / 6;
w = admoveconfig.movewidth -obj.offsetWidth;
h = admoveconfig.moveheight -obj.offsetheight;
x = x + step * kx * dirx;
if(x <0){dirx = 1; x = 0; kx = math.sin(rad); ky = math.cos(rad); }
如果(x> w){dirx = -1; x = w; kx = math.sin(rad); ky = math.cos(rad); }
y = y + step * ky * diry;
if(y <0){diry = 1; y = 0; kx = math.sin(rad); ky = math.cos(rad); }
如果(y> h){diry = -1; y = h; kx = math.sin(rad); ky = math.cos(rad); }
}
this.run = function(){
var延迟= 10;
Interval = setInterval(obj.customphod,延迟);
obj.onmouseover = function(){clear Interval(interval); }
obj.onmouseout = function(){intertal = setInterval(obj.custompOmpHod,delay); }
}
}
</script>
<! - 漂浮开始->
<div id = ad2 style =“ z-index:5;位置:相对”>
<a href ='partehtk.aspx'target ='_ blank'> <img src =“ images/fudong/fudong/fudong.jpg”> </a> <br> <br> <a href =“ href =“ onclick =” /> </a>
<! - 漂浮结束->
</div>
<script type =“ text/javascript” language =“ javaScript”>
var ad2 = new Admove(“ ad2”);
ad2.run();
//多组漂浮
</script>
<! - 首页图片漂浮结束->