Last Update:2017-08-24
Source: Internet
Author: User
Keywords
Web page production
Ajax
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.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>