Copy codeThe Code is as follows:
<! -- Homepage image floating start -->
<Script type = "text/javascript" language = "javascript">
Function addEvent (obj, evtType, func, cap ){
Cap = cap | false;
If (obj. addEventListener ){
Obj. addEventListener (evtType, func, cap );
Return true;
} Else if (obj. attachEvent ){
If (cap ){
Obj. setCapture ();
Return true;
} Else {
Return obj. attachEvent ("on" + evtType, func );
}
} Else {
Return false;
}
}
Function getPageScroll (){
Var xScroll, yScroll;
If (self. pageXOffset ){
XScroll = self. pageXOffset;
} Else if (document.doc umentElement & document.doc umentElement. scrollLeft ){
XScroll = document.doc umentElement. scrollLeft;
} Else if (document. body ){
XScroll = document. body. scrollLeft;
}
If (self. pageYOffset ){
YScroll = self. pageYOffset;
} Else if (document.doc umentElement & document.doc umentElement. scrollTop ){
YScroll = document.doc umentElement. scrollTop;
} Else if (document. body ){
YScroll = document. body. scrollTop;
}
ArrayPageScroll = new Array (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;
} Else {
XScroll = document. body. offsetWidth;
YScroll = document. body. offsetHeight;
}
Var implements wwidth, implements wheight;
If (self. innerHeight ){
Required wwidth = self. innerWidth;
Optional wheight = self. innerHeight;
} Else if (document.doc umentElement & document.doc umentElement. clientHeight ){
Required wwidth = document.doc umentElement. clientWidth;
Required wheight = document.doc umentElement. clientHeight;
} Else if (document. body ){
Required wwidth = document. body. clientWidth;
Optional wheight = document. body. clientHeight;
}
If (yScroll <windowHeight ){
PageHeight = running wheight;
} Else {
PageHeight = yScroll;
}
If (xScroll <1_wwidth ){
PageWidth = required wwidth;
} Else {
PageWidth = xScroll;
}
ArrayPageSize = new Array (pageWidth, pageHeight, expires wwidth, expires wheight)
Return 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 (window, "resize", AdMoveConfig. Resize );
AddEvent (window, "scroll", AdMoveConfig. Scroll );
Function 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 interval;
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, delay );
Obj. onmouseover = function () {clearInterval (interval );}
Obj. onmouseout = function () {interval = setInterval (obj. CustomMethod, delay );}
}
}
</Script>
<! -- Floating start -->
<DIV id = ad2 style = "Z-INDEX: 5; position: relative">
<A href = 'your ehtk. aspx 'target = '_ blank'> </a> <br> <a href = "#" onclick = "document. getElementById ('ad2 '). style. display = 'none' "> </a>
<! -- Floating End -->
</DIV>
<Script type = "text/javascript" language = "javascript">
Var ad2 = new AdMove ("ad2 ");
Ad2.Run ();
// Multiple floating groups
</Script>
<! -- Homepage image floating ends -->