JS随屏幕滚动广告

2019-03-08 network gramer 点击: 评论
<!DOCTYPE html PUBLIC "- W3C DTD XHTML 1 0 Transitional EN" "http: www w3 org TR xhtml1 DTD xhtml1-transitional dtd

天晟网小编整理编程教程 > JavaScript > 时看到JS随屏幕滚动广告 ,下面有小编47为你找到的38060相关内容希望对你47有所帮助。

<!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=gbk" />  
<title>JS随屏幕滚动广告 免费教程 www.timsion.com</title>  
<style>  
    html,body{  
        height:2000px;  
    }  
</style>  
</head>  
<body>  
    <div id="aa" style="width:200px;height:200px;background:#c0c0c0;" >JS随屏幕滚动广告<br/>免费教程 <br/>www.timsion.com</div>  
</body>  
</html>  
<script>  
    function scroll(p){  
        var d = document,w = window,o = d.getElementById(p.id),ie6 = /msie 6/i.test(navigator.userAgent);  
        if(o){  
            o.style.cssText +=";position:"+(p.f&&!ie6?'fixed':'absolute')+";"+(p.r?'left':"right")+":0;"+(p.t!=undefined?'top:'+p.t+'px':'bottom:0');  
            if(!p.f||ie6){  
                -function(){  
                    var t = 500,st = d.documentElement.scrollTop||d.body.scrollTop,c;  
                    c = st  - o.offsetTop + (p.t!=undefined?p.t:(w.innerHeight||d.documentElement.clientHeight)-o.offsetHeight);//如果你是html 4.01请改成d.body,这里不处理以减少代码  
                    c!=0&&(o.style.top = o.offsetTop + Math.ceil(Math.abs(c)/10)*(c<0?-1:1) + 'px',t=10);  
                    setTimeout(arguments.callee,t)  
                }()   
            }  
        }    
    }  
    scroll({  
        id:'aa'  
    })  
</script>

文章转载请注明来自天晟网 > 编程教程 > JavaScript >
原文标题:JS随屏幕滚动广告
原文网址:http://www.timsion.com/javas/38060.html

上一篇:js定时刷新页面的方法
下一篇:javascript中Array()数组详解

免责声明:以上内容来自互联网和用户投稿,不代表本站的观点和立场,版权归原作者所有,如有侵权,请与我们联系。