Compatible with IE and Firefox and can set up multiple floating ads

Source: Internet
Author: User
Keywords Web page production Ajax javascript
Tags ajax content document firefox function html http javascript

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">


<html xmlns= "http://www.w3.org/1999/xhtml" >


<head>


<title> Construction Station Teaching Network-Web Effects-window effects-compatible with IE and Firefox and can be set up a number of floating ads </title>


<meta http-equiv= "Content-type" content= "text/html;charset=gb2312" >


<!--Add the following code to <head> and </head>-->


<script type= "Text/javascript" >


<!--


//Common script file: Main.js


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.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;


}


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 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;


} else {


pageheight = Yscroll;


    }


if (Xscroll < windowwidth) {


pagewidth = windowwidth;


else {


pagewidth = Xscroll;


    }


arraypagesize = new Array (pagewidth,pageheight,windowwidth,windowheight)


return arraypagesize;


}


//AD script file: Admove.js


/*


Example:


<div id= "Div2" >


* * * content


</div>


var ad=new admove ("Div2");


AD. Run ();


*/


//////////////////////////////


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= "differs";


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>


</head>


<body>


<!--Add the following code to <body> and </body>-->


<div id= "GG1" style= "Width:100px;height:100px;background-color:red;color:yellow" >


Construction Station Teaching Network


</div>


<div id= "gg2" style= "Width:100px;height:100px;background-color:blue;color:yellow" >


www.jzread.com


</div>


<div id= "Gg3" style= "Width:100px;height:100px;background-color:green;color:yellow" >


http://www.jzread.com


</div>


<script type= "Text/javascript" >


<!--


var ad1=new admove ("GG1");


Ad1. Run ();


var ad2=new admove ("gg2");


ad2. Run ();


var ad3=new admove ("Gg3");


ad3. Run ();


//-->


</script>


</body>


</html>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.