|
本站源码安装服务:虚拟主机安装20元 win服务器安装30元 如果是买的本站源码,虚拟主机安装只需要15元
- <!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>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title></title>
- <style type="text/css">
- #souabAds1{
- position: absolute;
- top: 10px;
- left: 10px;
- }
- #souabAds2{
- position: absolute;
- top: 10px;
- right: 10px;
- }
- </style>
- </head>
- <body>
- <div id="souabAds1">
- <a href="http://bbs.idcbs.com" target="_blank"><img src="http://ubmcmm.baidustatic.com/media/v1/0f000Qtp4iI1lPVETOCDsf.jpg" border="0"></a>
- </div>
- <div id="souabAds2">
- <a href="http://bbs.idcbs.com" target="_blank"><img src="http://ubmcmm.baidustatic.com/media/v1/0f000Qtp4iI1lPVETOCDsf.jpg" border="0"></a>
- </div>
- <div style="height: 0px"></div>
- <script type="text/javascript">
- function StayPosition(speed)
- {
- this.objs = [];
- this.speed = speed || 0.1;
- this.timer = this.round = this.obj = this.end = null;
- if(StayPosition.initialize !== true){
- function correct(func, obj){
- return function(){
- func.call(obj);
- }
- }
- StayPosition.prototype.start = function(){
- this.timer = setInterval(correct(this.run, this), 33);
- }
- StayPosition.prototype.stop = function(){
- clearInterval(this.timer);
- }
- StayPosition.prototype.capitalize = function(prop){return prop.replace(/^[a-z]/, function(a){return a.toUpperCase();})}
- StayPosition.prototype.add = function(dom, prop){
- var offset = prop ? "offset" + this.capitalize(prop) : "offsetTop";
- var scroll = prop ? "scroll" + this.capitalize(prop) : "scrollTop";
- prop = prop ? prop : this.offset.slice(6).toLowerCase();
- this.objs.push({"dom": dom, "prop": {"size": dom[offset], "name": prop, "offset": offset, "scroll": scroll}});
- }
- StayPosition.prototype.run = function(){
- for(var i = 0, l = this.objs.length; i < l; i++){
- this.obj = this.objs[i];
- this.end = (document.documentElement[this.obj.prop.scroll] || document.body[this.obj.prop.scroll]) + this.obj.prop.size;
- if(this.end != this.obj.dom[this.obj.prop.offset]){
- this.round = this.end - this.obj.dom[this.obj.prop.offset] > 0 ? Math.ceil : Math.floor;
- this.obj.dom.style[this.obj.prop.name] = this.obj.dom[this.obj.prop.offset] + this.round((this.end - this.obj.dom[this.obj.prop.offset]) * this.speed) + "px";
- }
- }
- }
- }
- StayPosition.initialize = true;
- }
- var o = new StayPosition(0.2);
- o.add(document.getElementById("souabAds1"), "top");
- o.add(document.getElementById("souabAds2"), "top");
- o.start();
- //-->
- </script>
- </body>
- </html>
复制代码 |
|