图片跟着滚动条滚动

 <!--图片随滚动条滚动-->
    <script>
        guanggao = function (id, _top, _left) {
            var me = id.charAt ? document.getElementById(id) : id, d1 = document.body, d2 = document.documentElement;
            d1.style.height = d2.style.height = '100%'; me.style.top = _top ? _top + 'px' : 0; me.style[(_left > 0 ? 'left' : 'right')] = _left ? Math.abs(_left) + 'px' : 0;
            me.style.position = 'absolute';
            setInterval(function () { me.style.top = parseInt(me.style.top) + (Math.max(d1.scrollTop, d2.scrollTop) + _top - parseInt(me.style.top)) * 0.1 + 'px'; }, 10 + parseInt(Math.random() * 20));
            return arguments.callee;
        };
        window.onload = function () {
            guanggao
    ('demo1', 200, 10)


        }
    
         
    </script>
<a href="#"><img src="http://portal.edu.huizhoucloud.com/sites/zkzx/w/mb4/skin_default/images/h1.png"id="demo1" /></a> 

posted @ 2015-09-23 16:34  只是很孤单  阅读(437)  评论(0编辑  收藏  举报