QQ长图

QQ长图:
                        window.onload=function(){
                                        var oBox=document.getElementById("box");//盒子
                                        var aImg=oBox.getElementsByTagName('img')[0];//图片
                                        var oUp=document.getElementById("up");//向上按钮
                                        var oDown=document.getElementById("down");//向下按钮
                                        var num=0;         //向上向下移动的步码;
                                        var timer=null;
                                        function up(){
                                                num-=10;
                                                if(num<=-(aImg.offsetHeight-oBox.offsetHeight)){
                                                        clearInterval(timer);
                                                        num=-(aImg.offsetHeight-oBox.offsetHeight);}    //防止num小于-468,再次移入a中继续移动;
                                                aImg.style.top=num+'px'; //通过top值来使img运动
                                            }
                                        function down(){
                                                num+=10;
                                                if(num>=0){
                                                        clearInterval(timer);
                                                        num=0;}
                                                aImg.style.top=num+'px';
                                            }
                                        oUp.onmouseover=function(){           //上面按钮点击向上运动
                                                clearInterval(timer);               //清空定时器,防止继续移入多开定时器
                                                timer=setInterval(up,60);
                                        }
                                        oUp.onmouseout=function(){
                                                clearInterval(timer);
                                        }
                                        
                                        oDown.onmouseover=function(){
                                            clearInterval(timer);
                                            timer=setInterval(down,60);
                                        }
                                        oDown.onmouseout=function(){
                                            clearInterval(timer);
                                        }
                                    }

人生如戏,或实力或演技
原文地址:https://www.cnblogs.com/yang0902/p/5698011.html