复制代码代码如下:
<!-首页图片漂浮开始->
<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 () ؛
العودة صحيح.
} آخر {
return 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) ؛
إرجاع 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 ، PageHight ، 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 (نافذة ، "Scroll" ، admoveconfig.scroll) ؛
وظيفة الإعجاب (معرف) {
if (! 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 ؛
فاين الفاصل.
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 ؛
الفاصل الزمني = setInterval (obj.custommethod ، تأخير) ؛
obj.onmouseover = function () {clearinterval (الفاصل الزمني) ؛ }
obj.onmouseout = function () {steral = setInterval (obj.custommethod ، delay) ؛ }
}
}
</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'). style.display = 'none'" /> </a>
<!-漂浮结束->
</div>
<script type = "text/javaScript" language = "javaScript">
var ad2 = defove new ("ad2") ؛
ad2.Run () ؛
// 多组漂浮
</script>
<!-首页图片漂浮结束->