js 浮动广告代码

</p>
<p>function scrollx(p) {<br />
 var d = document, dd = d.documentElement, db = d.body, w = window, o = d.getElementById(p.id), ie6 = /msie 6/i.test(navigator.userAgent), timer;<br />
 if (o) {<br />
 cssPub = &quot;;position:&quot; + (p.f &amp;&amp; !ie6 ? 'fixed' : 'absolute') + &quot;;&quot; + (p.t != undefined ? 'top:' + p.t + 'px;' : 'bottom:0;');<br />
 if (p.r != undefined &amp;&amp; p.l == undefined) {<br />
 o.style.cssText += cssPub + ('right:' + p.r + 'px;');<br />
 } else if (p.r == undefined &amp;&amp; p.l != undefined) {<br />
 o.style.cssText += cssPub + ('left:' + p.l + 'px;');<br />
 }<br />
 if (p.f &amp;&amp; ie6) {<br />
 cssTop = ';top:expression(documentElement.scrollTop +' + (p.t == undefined ? dd.clientHeight - o.offsetHeight: p.t) + '+ &quot;px&quot; );';<br />
 cssRight = ';right:expression(documentElement.scrollright + ' + (p.r == undefined ? dd.clientWidth - o.offsetWidth : p.r) + ' + &quot;px&quot;)';<br />
 if (p.r != undefined &amp;&amp; p.l == undefined) {<br />
 o.style.cssText += cssRight + cssTop;<br />
 } else {<br />
 o.style.cssText += cssTop;<br />
 }<br />
 dd.style.cssText += ';background-image: url(about:blank);background-attachment:fixed;';<br />
 } else {<br />
 if (!p.f) {<br />
 w.onresize = w.onscroll = function() {<br />
 clearInterval(timer);// 清空时间移动<br />
 timer = setInterval(function() {<br />
 // 双选择为了修复CHROME 下XHTML解析时dd.scrollTop为 0<br />
 var st = (dd.scrollTop || db.scrollTop), c;<br />
 c = st - o.offsetTop + (p.t != undefined ? p.t : (w.innerHeight || dd.clientHeight) - o.offsetHeight);<br />
 if (c != 0) {<br />
 o.style.top = o.offsetTop + Math.ceil(Math.abs(c) / 10) * (c &lt; 0 ? -1 : 1) + 'px';<br />
 } else {<br />
 clearInterval(timer);// 清空时间移动<br />
 }<br />
 }, 10);<br />
 };<br />
 }<br />
 }<br />
 }<br />
}<br />
/*<br />
scrollx参数说明<br />
调用时传的是个对象<br />
id:浮动对象的id<br />
r:右边距(窗口右边距,不写为靠左浮动)<br />
l:左边距(窗口左边距) &quot;r&quot;和&quot;l&quot;只能有其中一个参数<br />
t:上边距(默认贴着底边,0是贴着顶边)<br />
f:1表示固定(不写或者0表示滚动)<br />
*/<br />
scrollx({<br />
id : 'loginForm',<br />
l : div_x,<br />
t : div_y,<br />
f : 0<br />
});</p>
<p>//相对父级相定固定<br />
scrollx({<br />
id : 'cover',<br />
l : 0,<br />
t : 0,<br />
f : 1<br />
});</p>
<p>