Lower right corner ad JS code

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

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


<html xmlns= "http://www.jzread.com/1999/xhtml" >


<head>


<meta. http-equiv= "Content-type" content= "HTML; CHARSET=GBK "/>


<title> lower right corner advertising code </title>


<style>


html,body{


padding:0;


margin:0;


}


</style>


</head>


<body>


<div id= "AA" style= "Width:100px;height:100px;background: #c0c0c0;" > I am rolling </div>


<div id= "BB" style= "Width:100px;height:100px;background: #c0c0c0;" > I still don't move </div>


<div style= "Width:100%;height:1500px;background: #000" ></div>


<div style= "Width:100%;height:1500px;background:green" ></div>


<div style= "width:100%;height:1500px;background:red" ></div>


</body>


</html>


<script>


function Scrollx (p) {


var d = document,dd = D.documentelement,db = D.body,w = Window,o = d.getElementById (p.id), IE6 =/msie 6/i.test ( navigator.useragent), Style,timer;


if (o) {


O.style.csstext + = ";p osition:" + (p.f&&!ie6?) Fixed ': ' differs ') + ";" + (p.l==undefined?) right:0 ': ' Left: ' +p.l+ ' px; + (p.t!=undefined?) Top: ' +p.t+ ' px ': ' bottom:0 ');


if (p.f&&ie6) {


O.style.csstext + = ' left:expression (documentelement.scrollleft + ' + p.l==undefined? DD.CLIENTWIDTH-O.OFFSETWIDTH:P.L) + ' + ' px '); Top:expression (documentelement.scrolltop + ' + ' + (p.t==undefined?) DD.CLIENTHEIGHT-O.OFFSETHEIGHT:P.T) + ' + ' px ');


Dd.style.cssText + = '; Background-image:url (About:blank); background-attachment:fixed; ';


}else{


if (!p.f) {


w.onresize = W.onscroll = function () {


clearinterval (timer);


timer = setinterval (function () {


//Dual selection to repair chrome under XHTML parsing dd.scrolltop is 0


var st = (dd.scrolltop| | Db.scrolltop), C;


C = st-o.offsettop + (p.t!=undefined?p.t: (w.innerheight| | Dd.clientheight)-o.offsetheight);


if (c!=0) {


o.style.top = o.offsettop + Math.ceil (Math.Abs (c)/10) * (c<0?-1:1) + ' px ';


}else{


clearinterval (timer);


}


},10)


}


}


}


}


}


Scrollx ({


ID: ' AA '


})


Scrollx ({


ID: ' BB ',


l:0,


t:200,


f:1


})


/*


ID of the content you want to scroll


L The position of the horizontal axis is not written to cling to the right


t where you want to put it on the page by default, the bottom 0 is affixed to the top edge


F 1 indicates a fixed not write or 0 for scrolling


*/


</script>

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.