复制代码代码如下:
<!-首页图片漂浮开始->
<script type = "text/javascript" language = "JavaScript">
ฟังก์ชั่น addevent (obj, evttype, func, cap) {
cap = cap || เท็จ;
if (obj.addeventListener) {
obj.addeventListener (evttype, func, cap);
กลับมาจริง;
} อื่นถ้า (obj.attachevent) {
if (cap) {
obj.setCapture ();
กลับมาจริง;
} อื่น {
ส่งคืน obj.attachevent ("on" + evttype, func);
-
} อื่น {
กลับเท็จ;
-
-
ฟังก์ชั่น getPagesCroll () {
var xscroll, yscroll;
if (self.pagexoffset) {
xscroll = self.pagexoffset;
} อื่นถ้า (document.documentElement && document.documentElement.scrollleft) {
xscroll = document.documentelement.scrollleft;
} อื่นถ้า (document.body) {
xscroll = document.body.scrollleft;
-
if (self.pageyoffset) {
yscroll = self.pageyoffset;
} อื่นถ้า (document.documentElement && document.documentElement.scrolltop) {
yscroll = document.documentelement.scrolltop;
} อื่นถ้า (document.body) {
yscroll = document.body.scrolltop;
-
ArrayPagesCroll = อาร์เรย์ใหม่ (XSCROLL, YSCROLL);
return arraypagescroll;
-
ฟังก์ชั่น getPagesize () {
var xscroll, yscroll;
if (window.innerHeight && window.scrollmaxy) {
xscroll = document.body.scrollwidth;
yscroll = window.innerHeight + window.scrollmaxy;
} อื่นถ้า (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;
ถ้า (self.innerHeight) {
windowwidth = self.innerWidth;
WindowHeight = self.innerHeight;
} อื่นถ้า (document.documentElement && document.documentElement.clientheight) {
windowwidth = document.documentelement.clientWidth;
windowheight = document.documentelement.clientheight;
} อื่นถ้า (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 = อาร์เรย์ใหม่ (pagewidth, pageheight, windowwidth, windowheight)
return arraypagesize;
-
var admoveConfig = วัตถุใหม่ ();
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 (หน้าต่าง "Scroll", AdmoveConfig.scroll);
ฟังก์ชั่น admove (id) {
ถ้า (! admoveConfig.isinitialized) {
admoveConfig.resize ();
admoveConfig.isinitialized = true;
-
var obj = document.getElementById (id);
obj.style.position = "สัมบูรณ์";
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); -
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 delay = 10;
Interval = 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 = "รูปภาพ/fudong/fudong.jpg"> </a> <br> <a href = "#" onclick = "document.getElementById ('ad2') /> </a>
<!-漂浮结束->
</div>
<script type = "text/javascript" language = "JavaScript">
var ad2 = new admove ("ad2");
Ad2.run ();
// 多组漂浮
</script>
<!-首页图片漂浮结束->