复制代码代码如下::
<!-首页图片漂浮开始->
<script type = "text/javaScript" Sprache = "JavaScript">
Funktion addEvent (obj, evtType, func, cap) {
Cap = Cap || FALSCH;
if (obj.addeventListener) {
obj.addeventListener (evttype, func, cap);
zurückkehren;
} else if (obj.attachEvent) {
if (cap) {
obj.setcapture ();
zurückkehren;
} anders {
return obj.attachevent ("on" + evtType, func);
}
} anders {
false zurückgeben;
}
}
Funktion 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 = New Array (xscroll, yScroll);
return ArrayPagesCroll;
}
Funktion 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.offseteight) {
xscroll = document.body.scrollwidth;
yScroll = document.body.scrollHeight;
} anders {
xscroll = document.body.Offsetwidth;
yScroll = document.body.offseteight;
}
var windowwidth, windowheight;
if (self.innerHeight) {
windowwidth = self.innnerwidth;
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;
} anders {
pageHeight = yScroll;
}
if (xscroll <windowwidth) {
pagewidth = windowwidth;
} anders {
pagewidth = xscroll;
}
ArrayPageSize = New Array (Pagewidth, PageHeight, Fensterbreite, Fensterheight)
ArrayPageSize return;
}
var admoveconfig = new Object ();
Admoveconfig.issinitialized = 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 (Fenster, "Größe", admoveconfig.Resize);
AddEvent (Fenster, "Scrollen", admoveconfig.scroll);
Funktion admove (id) {
if (! admoveconfig.issinitialisiert) {
AdmoveConfig.Resize ();
Admoveconfig.issinitialized = true;
}
var obj = document.getElementById (id);
Obj.Style.position = "Absolute";
var w = admoveconfig.movewidth - obj.offsetwidth;
var h = admoveconfig.moveHeight - obj.offseteight;
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 Schritt = 1;
var intervall;
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.offseteight;
x = x + Schritt * 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 + Schritt * 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 delay = 10;
Interval = setInterval (obj.Custommethod, Verzögerung);
obj.onmouseover = function () {ClearInterval (Intervall); }
obj.onmouseout = function () {interal = setInterval (obj.custommethod, delay); }
}
}
</script>
<!-漂浮开始->
<Div id = ad2 style = "z-Index: 5; Position: relativ">
<a href = 'polyhtk.aspx' target = '_ leer'> <img src = "Bilder/fudong/fudong.jpg"> </a> <br> <a href = "#" Onclick = "document.getElementById ('ad2'). /> </a>
<!-漂浮结束->
</Div>
<script type = "text/javaScript" Sprache = "JavaScript">
var ad2 = new admove ("ad2");
ad2.run ();
// 多组漂浮
</script>
<!-首页图片漂浮结束->