首页 > 代码库 > 关于javascript实现的网站页面侧边悬浮框"抖动"问题

关于javascript实现的网站页面侧边悬浮框"抖动"问题

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<style>
*{margin:0px; padding:0px;}
body{height:2000px;}
#div1{width:100px; height:200px; background:orange; position:absolute; left:0px; top:200px;}
</style>
<script>
window.onload = function(){
var oDiv = document.getElementById("div1");
window.onscroll = window.onresize = function(){
var oScrollH = document.documentElement.scrollTop || document.body.scrollTop;
oDiv.style.top = 200 + oScrollH + "px"; 
}; 
};
</script>
</head>

<body>
<div id="div1"></div>
</body>
</html>

关于javascript实现的网站页面侧边悬浮框"抖动"问题