为什么js不会动?按视频上说的做的

html====

 \<body style="height:1000px">
\<div id="box">\</div>

    css======
    *{margin: 0;padding: 0;}
#box{width: 100px;height: 100px;background: red;position: absolute;right: 0;bottom: 0;}
js========
window.onscroll=function  () {
    var box=document.getElementById('box');
    var scrollTop=document.documentElement.scrollTop||document.body.scrollTop;
    box.style.top=document.documentElement.clientHeight-box.offsetHeight+scrollTop+"px";
}

你也将代码贴全啊,就这个样子谁也猜不出来的

你样式和脚本放到了style和script没有,要下面这样,没问题,一直在右下角浮动

  <body style="height:1000px">
   <div id="box"></div>
</body>
<style>
    *{margin: 0;padding: 0;}
    #box{width: 100px;height: 100px;background: red;position: absolute;right: 0;bottom: 0;}
     </style >
<script>
    window.onscroll = function () {
         var box=document.getElementById('box');
         var scrollTop=document.documentElement.scrollTop||document.body.scrollTop;
         box .style.top=document.documentElement.clientHeight-box.offsetHeight+scrollTop+"px";
 }
</script>

教你一个办法查看错误,用chrome 浏览器,打开这个页面,按 F12,在console一栏里会看到错误