复制代码代码如下:
<!-首页图片漂浮开始->
<script type = "text/javascript" ranguage = "javascript">
Функция addEvent (obj, evttype, func, cap) {
cap = cap || ЛОЖЬ;
if (obj.addeventlistener) {
obj.addeventlistener (evttype, func, cap);
вернуть истину;
} else if (obj.attachevent) {
if (cap) {
obj.setCapture ();
вернуть истину;
} еще {
вернуть obj.attachevent ("on" + evttype, func);
}
} еще {
вернуть ложь;
}
}
функция getPagesCroll () {
var xscroll, yscroll;
if (self.pagexoffset) {
xscroll = self.pagexoffset;
} else if (document.documentelement && document.documentelement.scrollleft) {
xscroll = document.documentelement.scrollleft;
} else if (document.body) {
xscroll = document.body.scrollleft;
}
if (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 = новый массив (xscroll, yscroll);
return Arraypagescroll;
}
function 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 Windowwidth, WindowHeight;
if (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;
}
if (yscroll <windowheight) {
PageHeight = WindowHeight;
} еще {
PageHeight = yScroll;
}
if (xscroll <windowwidth) {
PageWidth = Windowwidth;
} еще {
pagewidth = xscroll;
}
ArrayPagesize = New Array (PageWidth, PageHeight, Windowwidth, WindowHeight)
return ArrayPagesize;
}
var ammoveconfig = new object ();
Ammoveconfig.isinitialized = false;
Ammoveconfig.scrollx = 0;
Ammoveconfig.scroly = 0;
Ammoveconfig.movewidth = 0;
Ammoveconfig.moveheight = 0;
Ammoveconfig.resize = function () {
var winsize = getPagesize ();
Ammoveconfig.movewidth = winsize [2];
Ammoveconfig.moveheight = winsize [3];
Ammoveconfig.scroll ();
}
Ammoveconfig.scroll = function () {
var winscroll = getPagescroll ();
Ammoveconfig.scrollx = winscroll [0];
Ammoveconfig.scroly = winscroll [1];
}
addEvent (window, «resize», ammoveconfig.resize);
addevent (window, "scrolk", ammoveconfig.scroll);
Функция Admove (id) {
if (! ammoveconfig.isinitialized) {
Ammoveconfig.resize ();
Ammoveconfig.isinitialized = true;
}
var obj = document.getElementbyId (id);
obj.style.position = "Absolute";
var w = ammoveconfig.movewidth - obj.offsetwidth;
var h = ammoveconfig.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.scroly) + "px";
rad = (math.random () + 1) * math.pi / 6;
W = ammoveconfig.movewidth - obj.offsetwidth;
H = ammoveconfig.moveheight - obj.offsetheight;
x = x + step * kx * dirx;
if (x <0) {dirx = 1; x = 0; kx = math.sin (rad); ky = math.cos (rad); }
if (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); }
if (y> h) {diry = -1; y = h; kx = math.sin (rad); ky = math.cos (rad); }
}
this.run = function () {
var задержка = 10;
интервал = setInterval (obj.custommethod, задержка);
obj.onmouseover = function () {clearInterval (интервал); }
obj.onmouseout = function () {interval = setInterval (obj.custommethod, задержка); }
}
}
</script>
<!-漂浮开始->
<Div id = ad2 style = "z-index: 5; позиция: относительно">
<a href = 'policehtk.aspx' target = '_ blank'> <img src = "images/fudong/fudong.jpg"> </a> <br> <a href = "#" onclick = "document.getElementbyId ('ad2'). /> </a>
<!-漂浮结束->
</Div>
<script type = "text/javascript" ranguage = "javascript">
var ad2 = new Admove ("ad2");
ad2.run ();
// 多组漂浮
</script>
<!-首页图片漂浮结束->